Day-12 Flashcards

1
Q

Blocks

A

Serve the exact same purpose as Closures in Swift

Can be anonymous or stored local variables or properties, same as closures

When referring to self inside a block (or closure), best practice is to create a weak reference of self before the block and use that reference instead of self

Capture a weak version of self outside a block and strong reference inside so we don’t lose the connection and cause retain cycle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Core Location

A

Core Location provides several services that you can use to get and monitor the devices current location

The significant-change location service provides a low power way to get the current location and be notified when significant changes occur

The standard location service offers a highly configurable way to get current location and track changes

Region monitoring lets you monitor the boundary crossing defined by geographical regions and bluetooth low energy beacon regions.

You should always call locationServicesEnabled class method on CLLocationManager before attempting to start services. If it returns NO and you attempt to start the services anyway, the user will be prompted to turn on the services, which may be annoying after one time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

CLLocationManager commands

A
authorizationStatus()
locationManager:didChangeAuthorizationStatus
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
 desiredAccuracy
distanceFilter 
distance
accuracy
startUpdatingLocation
stopUpdatingLocation

To begin monitoring significant changes, setup your CLLocationManager with a delegate, and then call startMonitoringSignificantLocationChanges method

The location manager reports to the delegate by sending locationManager:didUpdateLocations: method

If theres an error with the location, it sends locationManager:didFailWithError:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

CLLocation represents location data

A

coordinate - CLLocationCoordinate2D - struct with two values: latitude and longitude, both in degrees. Positive values north of equator and negative south of the equator

altitude - CLLocationDistance - A double, positive values indicate above the sea level, negative below

course - CLLocationDirection - The direction in which the device is traveling. Measured in degrees starting at due north and continuing clockwise. North is 0 degrees, east is 90,etc. Negative means invalid

horizontalAccuracy - CLLocationAccuracy - A double, the lat and long identify the center of the circle, this value indicates the radius of that circle.
(THIS IS AWESOME :) - Shows the big blue circle blinking before finding the accurate location of a device.

timeStamp - NSDate - can be used to figure out how ‘stale’ the location update is. Use timeIntervalSinceNow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Map View Annotation

A

Annotations display content that can be defined by a single coordinate point

User’s current location, a specific address, single points of interest, etc

Remain fixed to the map

1) The annotation object needs a value set for its title property or the callout wont show
2) Set the canShowCallout property to true on the annotation view
3) Has left and right accessoryView properties that can be set to buttons, images, etc
4) mapView:calloutAccessoryControlTapped: tells you which annotation and callout was tapped

How well did you know this?
1
Not at all
2
3
4
5
Perfectly