본문 바로가기

Programming/Swift

(68)
Class: JSONSerialization An object that converts between JSON and the equivalent Foundation objects. Declaration class JSONSerialization : NSObject Overview You use the JSONSerialization class to convert JSON to Foundation objects and convert Foundation objects to JSON. A Foundation object that may be converted to JSON must have the following properties: The top level object is an NSArray or NSDictionary. All objects ar..
Instance Method: dataTask(with:completionHandler:) Creates a task that retrieves the contents of the specified URL, then calls a handler upon completion. Declaration func dataTask(with url: URL, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask The dataTask method passed back 3 values, all of which are optional - Data?, URLResponse?, and Error?. developer.apple.com/documentation/foundation/urlsession/14103..
NSError & CocoaError Information about an error condition including a domain, a domain-specific error code, and application-specific information. Declaration class NSError : NSObject Overview Objective-C methods can signal an error condition by returning an NSError object by reference, which provides additional information about the kind of error and any underlying cause, if one can be determined. An NSError object ..
Error Declaration protocol Error Overview Any type that declares conformance to the Error protocol can be used to represent an error in Swift’s error handling system. Because the Error protocol has no requirements of its own, you can declare conformance on any custom type you create. Describing an Error var localizedDescription: String Retrieve the localized description for this error. developer.apple..
Protocols A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the requirements of a protocol is said to conform to that protocol. In addition to specifying requirements that..
When to Use Inheritance Inheritance is a useful programming concept, but it is easy to use inappropriately. Often interfaces do the job better. This topic and When to Use Interfaces help you understand when each approach should be used. Inheritance is a good choice when: Your inheritance hierarchy represents an "is-a" relationship and not a "has-a" relationship. You can reuse code from the base classes. You need to app..
Class: UIPickerView A view that uses a spinning-wheel or slot-machine metaphor to show one or more sets of values. Declaration class UIPickerView : UIView Overview A picker view displays one or more wheels that the user manipulates to select items. Each wheel—known as a component—has a series of indexed rows representing the selectable items. Each row displays a string or view so that the user can identify the item..
Class: URLSession An object that coordinates a group of related, network data-transfer tasks. Declaration class URLSession : NSObject Overview The URLSession class and related classes provide an API for downloading data from and uploading data to endpoints indicated by URLs. Your app can also use this API to perform background downloads when your app isn’t running or, in iOS, while your app is suspended. You can ..
UICollectionViewFlowLayout A layout object that organizes items into a grid with optional header and footer views for each section. Declaration class UICollectionViewFlowLayout : UICollectionViewLayout Overview A flow layout is a type of collection view layout. Items in the collection view flow from one row or column (depending on the scrolling direction) to the next, with each row containing as many cells as will fit. Ce..
UITableViewDelegate Methods for managing selections, configuring section headers and footers, deleting and reordering cells, and performing other actions in a table view. Declaration protocol UITableViewDelegate Overview Use the methods of this protocol to manage the following features: Create and manage custom header and footer views. Specify custom heights for rows, headers, and footers. Provide height estimates ..