Skip to content

Commit

Permalink
docs for background
Browse files Browse the repository at this point in the history
  • Loading branch information
alazier committed Jul 15, 2014
1 parent 7d0ba4e commit 8cfbea8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion docs/src/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,28 @@ Realm can be very efficient when writing large amounts of data by batching toget
<div class="highlight-wrapper">

{% highlight swift %}
dispatch_async(queue, {

// Get realm and table instances for this thread
var realm = RLMRealm.defaultRealm()

// Break up the writing blocks into smaller portions
// by starting a new transaction
for (var idx1 = 0; idx1 < 1000; idx1++) {
realm.beginWriteTransaction()

// Add row via dictionary. Order is ignored.
for (var idx2 = 0; idx2 < 1000; idx2++) {
Person.createInDefaultRealmWithObject(
["name": "\(idx1)", "age": idx2]
);
}

// Commit the write transaction
// to make this data available to other threads
realm.commitWriteTransaction()
}
});
{% endhighlight%}

{% highlight objective-c %}
Expand Down Expand Up @@ -602,7 +623,7 @@ Since the result set is given to us as an array we can simply add it straight to

{% highlight swift %}
//Extract the array of venues from the response
var venues = json.objectForKey("venues") as Array
var venues: AnyObject! = json.objectForKey("venues")

defaultRealm.beginWriteTransaction()
// Save one Venue object (& dependents) for each element of the array
Expand Down

0 comments on commit 8cfbea8

Please sign in to comment.