Repository: realm/realm-swift
File: examples/iOSTutorial/AppDelegate.m (Objective-C)

Code before:
    // @@EndExample@@

    // @@Example: insert_rows @@

    // Add a row
    PeopleTable_Cursor *cursor;
    cursor = [people addEmptyRow];
    cursor.Name  = @"John";
    cursor.Age   = 21;
    cursor.Hired = YES;

    // Add more rows
    [people appendRow:@{@"Name": @"Mary", @"Age": @76, @"Hired": @NO}];
    [people appendRow:@{@"Name": @"Lars", @"Age": @22, @"Hired": @YES}];
    [people appendRow:@{@"Name": @"Phil", @"Age": @43, @"Hired": @NO}];
    [people appendRow:@{@"Name": @"Anni", @"Age": @54, @"Hired": @YES}];

    // @@EndExample@@

    // @@Example: insert_at_index @@
    [people insertRow:@{@"Name": @"Frank", @"Age": @34, @"Hired": @YES} atRowIndex:2];

    // @@EndExample@@

    // @@Example: number_of_rows @@
    NSUInteger cnt1 = people.rowCount;                 // cnt = 6
    BOOL empty = people.rowCount;                      // empty = NO
    // @@EndExample@@

    // @@Example: accessing_rows @@
    // Getting values directly
    NSString* name = people[5].Name;                   // =&gt; 'Anni'

    // Using a cursor
    PeopleTable_Cursor *myRow = people[5];
    int64_t age = myRow.Age;                           // =&gt; 54
    BOOL hired  = myRow.Hired;                         // =&gt; true

    // Setting values
    people[5].Age = 43;                                // Getting younger
    myRow.Age += 1;                                    // Happy birthday!
    // @@EndExample@@

    // @@Example: last_row @@
    NSString *last = [people cursorAtLastIndex].Name;  // =&gt; "Anni"
    // @@EndExample@@

    // @@Example: updating_entire_row @@
    people[4] = @{@"Name": @"Eric", @"Age": @50, @"Hired": @YES};
    // @@EndExample@@


Review comment (suggestion):
A property can be used as a getter:

```
[table rowCount]
```

When declaring a property like `rowCount`, two things happen:
- A getter and a setter method is synthesized at compile time (only a getter if 'readonly').
- You enable the `.` syntax as a shorthand for calling the getter and setter. 


Code after:
    // @@EndExample@@

    // @@Example: insert_rows @@

    // Add a row
    PeopleTable_Cursor *cursor;
    cursor = [people addEmptyRow];
    cursor.Name  = @"John";
    cursor.Age   = 21;
    cursor.Hired = YES;

    // Add more rows
    [people appendRow:@{@"Name": @"Mary", @"Age": @76, @"Hired": @NO}];
    [people appendRow:@{@"Name": @"Lars", @"Age": @22, @"Hired": @YES}];
    [people appendRow:@{@"Name": @"Phil", @"Age": @43, @"Hired": @NO}];
    [people appendRow:@{@"Name": @"Anni", @"Age": @54, @"Hired": @YES}];

    // @@EndExample@@

    // @@Example: insert_at_index @@
    [people insertRow:@{@"Name": @"Frank", @"Age": @34, @"Hired": @YES} atRowIndex:2];

    // @@EndExample@@

    // @@Example: number_of_rows @@
    NSUInteger cnt1 = people.rowCount;                 // cnt = 6
    BOOL empty = people.rowCount == 0;                 // empty = NO
    // @@EndExample@@

    // @@Example: accessing_rows @@
    // Getting values directly
    NSString* name = people[5].Name;                   // =&gt; 'Anni'

    // Using a cursor
    PeopleTable_Cursor *myRow = people[5];
    int64_t age = myRow.Age;                           // =&gt; 54
    BOOL hired  = myRow.Hired;                         // =&gt; true

    // Setting values
    people[5].Age = 43;                                // Getting younger
    myRow.Age += 1;                                    // Happy birthday!
    // @@EndExample@@

    // @@Example: last_row @@
    NSString *last = [people cursorAtLastIndex].Name;  // =&gt; "Anni"
    // @@EndExample@@

    // @@Example: updating_entire_row @@
    people[4] = @{@"Name": @"Eric", @"Age": @50, @"Hired": @YES};
    // @@EndExample@@