From IT Skills
Jump to: navigation, search

[NSClassFromString(...) alloc] is analog of Activator.CreateInstanceFrom(...) in C#

Introspection is like reflection in C#... isKindOfClass:, respondsToSelector:, conformsToProtocol:


Regular Expression Metacharacters

encoding and archiving[edit]

is like DeAndSerialization in C#... encodeWithCoder: NSCoder declares an extensive interface for taking the information stored in an object and putting it into another format suitable for writing to a file, transmitting between processes or across a network... Only objects whose class conforms to the NSCoding protocol can be written to an archive.

The “keyed” archiver class (NSKeyedArchiver and NSKeyedUnarchiver) associate an encoded value with a string key and use that same key when decoding that value; thus instance variables can be encoded and decoded in any sequence. With the other type of coder (NSArchiver and NSUnarchiver) you encode instance variables in a certain sequence, and you must decode them in the same sequence. The sequential coders should be used only with legacy code; new subclasses should use keyed archive coders.

Archiving is the process of converting a group of related objects to a form that can be stored or transferred between applications. The end result of archiving—an archive—is a stream of bytes
archiveRootObject:toFile: class method of NSKeyedArchiver. Starting with this root object, each object in the graph that conforms to the NSCoding protocol is given an opportunity to encode itself into the archive.


simple way to get a JSON representation from your menu is to provide a Dictionary representation... NSDictionary dictionaryWithObjectsAndKeys:

Swift’s JSON support

Codable protocol in Swift#4, which allows you to encode and decode your model types to data types such as JSON and property lists, and can be used instead of the NSCoding protocol... the magic of the Codable protocol is that it has the power to automatically generate both of its required methods (encode and init) and the CodingKeys enum
Codable is only available to Swift only... you can use Codable together with Obj-C. The tricky part is that because Obj-C can't see Decoder, so you will need to create a helper class method

Subcategories

This category has the following 4 subcategories, out of 4 total.

A

I

  • IOS(2 P)

Pages in category "Apple development"

The following 10 pages are in this category, out of 10 total.