Note that there are some explanatory texts on larger screens.

plurals
  1. POYour Second iOS App: Edit one object in two different views
    primarykey
    data
    text
    <p>I am going through the tutorials provided by Apple and tried to improve <a href="http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/SecondiOSAppTutorial/Introduction/Introduction.html" rel="nofollow">"My Second iOS App"</a>, the app for bird sightings. <em>(There is a MasterView where all entered sightings are listed. If you click one, you are directed to a DetailView of the sighting. You can add a sighting and are asked to enter a name and location.)</em></p> <p>I want to sepperate the views for entering the birds name and location.</p> <p>So I have two views (one for entering the name and one for entering the location) and one object I want to store.</p> <p>In the file <code>BirdSighting.m</code> I added the following methods</p> <pre><code>-(id)initWithNameOnly:(NSString *)name date:(NSDate *)date { self = [super init]; if (self) { _name = name; _date = date; return self; } return nil; } </code></pre> <p>and</p> <pre><code>-(id)setLocation:(NSString *)location { if (self) { _location = location; return self; } return nil; } </code></pre> <p>In the <code>AddSightingNameViewController.m</code> I implemented the following code</p> <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"ToLocation"]) { if ([self.birdNameInput.text length]) { BirdSighting *sighting; NSDate *today = [NSDate date]; sighting = [[BirdSighting alloc] initWithNameOnly:self.birdNameInput.text date:today]; self.birdSighting = sighting; } } } </code></pre> <p>The view for entering the name leads with a push segue to the location-view. There has'nt been changed much else.</p> <p><strong>Now how do I pass the object generated in the first view to the second?</strong> And how do I call the <code>setLocation</code> method on this specific object in <code>AddSightingLocationViewController.m</code>? Do I have to define different properties? And how do I finally display the object in the MasterView with the correct data after I entered the location?</p> <p>As this code is not working yet, I don't even know if it is working, what I am trying to do. So please be gentle, if this is crappy code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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