Skip to content

Commit

Permalink
Merge branch 'kg-doc-samples-cleanup' of github.com:Realm/realm-cocoa…
Browse files Browse the repository at this point in the history
… into kg-doc-samples-cleanup
  • Loading branch information
kneth committed Jul 14, 2014
2 parents a3068bd + c95816d commit f36aede
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions docs/src/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ For example, the following calls `[RLMObject objectsOrderedBy:where:]` to sort t
{% highlight objective-c %}
// Using a string (sort is ascending by default)
RLMArray *dogs = [[Dog objectsWithPredicateFormat:@"color = 'tan' AND name BEGINSWITH 'B'"]
arraySortedByProperty:@"name" ascending:YES];
arraySortedByProperty:@"name" ascending:YES];
{% endhighlight %}

</div><!--/highlight-wrapper -->
Expand Down Expand Up @@ -506,7 +506,7 @@ There are several ways we may want to import this JSON into our Realm. You could
@interface Venue : RLMObject
@property NSString *id;
@property NSString *name;
@property Contact *contact;
@property Contact *contact;
@property Location *location;
@end

Expand All @@ -517,8 +517,8 @@ There are several ways we may want to import this JSON into our Realm. You could

// Location.h
@interface Location : RLMObject
@property double lat;
@property double lng;
@property double latitude;
@property double longitude;
@property NSString *postalCode;
@property NSString *cc;
@property NSString *state;
Expand Down Expand Up @@ -560,9 +560,9 @@ When working with any database, it is likely your data model will change over ti

{% highlight objective-c %}
@interface Person : RLMObject
@property NSString *firstName
@property NSString *lastName
@property int age
@property NSString *firstName;
@property NSString *lastName;
@property int age;
@end
{% endhighlight %}
</div><!--/highlight-wrapper -->
Expand All @@ -577,8 +577,8 @@ Next, we want to update the data model to require a 'fullName' property, rather

{% highlight objective-c %}
@interface Person : RLMObject
@property NSString *fullName
@property int age
@property NSString *fullName;
@property int age;
@end
{% endhighlight %}
</div><!--/highlight-wrapper -->
Expand Down Expand Up @@ -610,8 +610,7 @@ RLMMigrationBlock migrationBlock = ^NSUInteger(RLMMigration *migration,
if (oldSchemaVersion < 1) {
// Nothing to do!
// Realm will automatically detect new properties & removed properties
// And will update the schema on disk automatically
}
// And will update the schema on disk automatically
}
// Return the latest version number (always set manually)
// Must be a higher than the previous version or an RLMException is thrown
Expand Down Expand Up @@ -674,18 +673,18 @@ Suppose now we change the data model for the 'Person' subclass yet again, for a

{% highlight objective-c %}
// v0
@property NSString *firstName
@property NSString *lastName
@property int age
@property NSString *firstName;
@property NSString *lastName;
@property int age;

// v1
@property NSString *fullName //new property
@property int age
@property NSString *fullName; // new property
@property int age;

// v2
@property NSString *fullName
@property NSString *email //new property
@property int age
@property NSString *fullName;
@property NSString *email; // new property
@property int age;
{% endhighlight %}
</div><!--/highlight-wrapper -->

Expand All @@ -707,12 +706,12 @@ The logic in our migration block might look like the following.
oldObject[@"firstName"],
oldObject[@"lastName"]];
}

// Add the 'email' property to Realms with a schema version of 0 or 1
if (oldSchemaVersion < 2) {
newObject[@"email"] = [[NSString alloc] init];
}

return 2;
}];
{% endhighlight %}
Expand Down

0 comments on commit f36aede

Please sign in to comment.