UIAlertView
is deprecated, so use it for iOS 7 compatibility. Otherwise, use UIAlertController
.
let alertView = UIAlertView()
alertView.message = "here"
alertView.addButtonWithTitle("Ok")
alertView.show()
tabBarController?.tabBar.selectedImageTintColor = .redColor() |
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView!{ | |
// user location | |
if annotation is MKUserLocation { | |
(annotation as! MKUserLocation).title = "" | |
// use blue pulsy instead of pin | |
return nil | |
} | |
// other pins | |
return mapView.dequeueReusableAnnotationViewWithIdentifier("pin") as? MKPinAnnotationView | |
} |
dispatch_async(dispatch_get_main_queue()) { | |
self.someMethod(self.someProperty) | |
} |
This assumes you have SwiftyJSON.
Start with a Dictionary
let paramsDictionary = [
"title": "foo",
"description": "bar"
See http://krakendev.io/blog/the-right-way-to-write-a-singleton
This creates a new User
if necessary, or uses the existing one.
class User {
static let sharedInstance = User()
var name = "Bruce"
You want to iterate over an array of custom objects, and need to tell whether two objects are equal. You're not concerned with two objects being identical in memory, but equivalent based on your own definition.
class Student {
var studentId = 0
var firstName = "Bob"
}