스탠포드 iOS 강의노트 L15,16

Lecture 15,16

Notification, Alert, File system, URL, LifeCycle, Segues

Course Description Updated for iOS 10 and Swift. Tools and APIs required to build applications for the iPhone and iPad platforms using the iOS SDK. User interface design for mobile devices and unique user interactions using multi-touch technologies. Object-oriented design using model-view-controller paradigm, memory management, Swift programming language. Other topics include: object-oriented database API, animation, mobile device power management, multi-threading, networking and performance considerations.

NotificationCenter.default

var observer: NSObjectProtocol
observer = NotificationCenter.default.addObserver (
	forName: NSNotification.Name, // the name of the radio station
	object: Any?, // the broadcaster (or nil for anyone)
	queue: OperationQueue? // the queue on which to dispatch the closure below
) { (notification: Notification) -> Void in 
	let info: Any? = notification.userInfo
	// info is usually a dictionary of notification-specific information
}

URL

URLs are the preferred way to refer to local files. Most objects that read data from or write data to a file have methods that accept a URL instead of a pathname as the file reference. For example, you can get the contents of a local file URL as String by calling func init(contentsOf:encoding) throws, or as a Data by calling func init(contentsOf:options) throws.

File System

Steps of accessing files in the Unix filesystem

FileManager (Class)

When specifying the location of files, you can use either NSURL or NSString objects. The use of the NSURL class is generally preferred for specifying file-system items because they can convert path information to a more efficient representation internally.

App Delegate