Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Class Extensions should be used on classes you implement yourself as a way of keeping ivars and some properties hidden from the header File, that should contain only stuff that should be visible outside the class (and ivars are't that kind of stuff).</p> <p>Categories are used on classes already implemented, as a way of adding additional functionality. They are usually needed when you want to add a general kind of behavior to a known Class. E.g. adding a method to NSString <strong>+(NSString*)reversedString;</strong> that returns a reversed instance so you can then use it like this: </p> <pre><code>NSString *someString = @"string"; NSString *reverse = [someString reversedString]; NSLog(@"%@", someString); //this would output "gnirts" </code></pre> <p>.</p> <p>Regarding your particular problem, I can assure you that your CoreDataModel does not contain NSURL or NSData. The supported types are primitives, strings, binary Data and transformables. So, if you want to, you can subclass NSData or NSURL and then use it with CoreData by setting the type to "transformable". And after you have done this, you can then subclass NSData as you wish and use class extensions in the process, or just use a category to add the methods you require to the class. </p> <p><em>Quote from Apple about <strong>transformable attributes</strong>:</em></p> <blockquote> <p>The idea behind transformable attributes is that you access an attribute as a non-standard type, but behind the scenes Core Data uses an instance of NSValueTransformer to convert the attribute to and from an instance of NSData. Core Data then stores the data instance to the persistent store.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload