I have created an Cocoa Touch framework with Swift and and created a CocoaPod from it. I imported that framework with CocoaPod into my app project in Swift. In the view-controller where I want to use the framework I add the following:
import UIKit
import swiftBAOS
class ViewController: UIViewController
{
override func viewDidLoad() {
super.viewDidLoad()
BAOS.login()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
There is no error, but when I want to use a class from the framework Xcode gives the following error: "Use of unresolved identifier BAOS"
I hope somebody can help. Thanks.
Related
I am building an app that should connect to my raspberry pi but after installing MQTT via cocoaPods the import CocoaMQTT gives me this error
"Could not build Objective-C module 'CocoaMQTT'"
I've already deleted my derivedData but thats not working either.
how can I fix this?
import UIKit
import CocoaMQTT -> Could not build Objective-C module 'CocoaMQTT'
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
#IBAction func test(_ sender: UISwitch) {
}
}
Ok i've fixed it by compiling for a lower iOS deployment.
I am new to programming, but I am interested in how to use iosMath for iOS. I could instal Cocoa Pod already and I did import iosMath to project. Question is: how to visualise math equations?
I understand that it should be used MTMathUILabel for that, however I do not know, how to add it to program. Is there a way how to create subclass of UIView or something, to be able able to do it?
Here sample of my code:
import UIKit
import Foundation
import CoreGraphics
import QuartzCore
import CoreText
import iosMath
class ViewController: UIViewController {
#IBOutlet weak var label: MTMathUILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let label: MTMathUILabel = MTMathUILabel()
label.latex = "x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}"
label.sizeToFit()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I tried to connect label to UIView() and UILabel() in my Storyboard, but obviously thats not how it works.
Thank you in advance for any help.
A few problems in your posted code
You are setting an IBOutlet then instantiating another MTMathUILabel with the same name
You don't really need to call label.sizeToFit()
Simple solution is to remove the IBOutlet, and do as follows
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let label: MTMathUILabel = MTMathUILabel()
label.latex = "x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}"
//ADD THIS LABE TO THE VIEW HEIRARCHY
view.addSubview(label)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Better solution is as follows:
Create a UIView in storyboard (because MTMathUILabel is actually a UIView)
Set this view's class to MTMathUILabel
Connect the IBOutlet for this view
then use the following code
class ViewController: UIViewController {
#IBOutlet weak var label: MTMathUILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//NO NEED TO INSTANTIATE A NEW INSTANCE HERE
label.latex = "x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}"
//NO NEED TO CALL sizeToFit()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
In Xcode 7.3 (using Swift) I've created the most simple map example:
Imported MapKit
Created an outlet called mapView
For some reason, there's no autocomplete with my outlet. Even when I type 'ma' it does not come up with the outlet name 'mapView'.
Can anyone help get autocomplete working?
Code from: ViewController.swift
import UIKit
import MapKit
class ViewController: UIViewController {
#IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// mapView doesnt appear when I begin to type it
// also it doesn't show any functions when I type mapView.
}
I've also uploaded my project to dropbox:
https://www.dropbox.com/sh/rgefwafhanti1wa/AABhQt8TsbvesaO9zg-SydlRa?dl=0
You also need to add the MapKit framework in Build Phases for the target.
I've been trying to set up the CocoaPods CVCalendar for my app, but after integrating it into my Xcode project, the content fails to show through the UIViews. Essentially, whenever I connect the views to the CVCalendarView and CVCalendarMenuView variables, the views simply do not show. Here's the ViewController code I have so far, and help would be greatly appreciated!
import UIKit
import CVCalendar
class ViewController: UIViewController, CVCalendarViewDelegate, CVCalendarMenuViewDelegate {
#IBOutlet weak var menuView: CVCalendarMenuView!
#IBOutlet weak var calendarView: CVCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
calendarView.commitCalendarViewUpdate()
menuView.commitMenuViewUpdate()
}
func presentationMode() -> CalendarMode {
return .MonthView
}
func firstWeekday() -> Weekday {
return .Sunday
}
}
Your ViewController class is the class in the storyboard?
Did you hook up the delegates? Delegate setup
You're delegating the rendering to your ViewController/
You need to drag to the yellow view controller nub.
If for some reason you'd like to setup CVCalendar manually you have to do the following steps.
Refer here
I'm new in swift and I'm studying the delegate and protocols. In my test application I'm using this protocol declaration (in ViewController1) and I have this code:
import UIKit
//Protocol declaration
protocol viewController1Delegate
{
func didFinish(controller:ViewController1,text:String)
}
//ViewController1 class
class ViewController1: UIViewController {
//delegate declaration for viewController1
var delegate:ViewController1? = nil
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
valore.text=valoreInput
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func doneWithOK(sender: AnyObject) {
delegate?.didFinish(self,"done")
}
}
My problem is XCode show me an error: ViewController1 does not have a member named didFinisch. What is wrong in my code? Someone can help me to understand the problem?
delegate should be viewController1Delegate? and not ViewController1?.