Presence2 CLEARED Topics CS193P iPhone

1. Why is Person *twit = [Person *twit]alloc init] yield local declaration error hides instance variable, but twit = [Person *twit]alloc init] works fine? Because Person *object = is used to declare the object for the first time.  So if you call this line in your implementation code, it will give that warning.  Whereas object = works fine because youre just alloc/initing an object after it has been declared in the h file…it must have been declared in the h file or in the imported Class Object File for it to work.

2. NSIndex & indexPath.row knows to get more elements in the array because we passed it a value for numberOfRowsInSection just because its inherent behavior.  You need to pass it an object you can cycle thru by nature of that object, otherwise itll keep trying to get more values from that object you passed it.

3.  Conceptually understand each of these scenarios and the difference between both:

SCENARIO 1

twit = [[Person alloc] init];
twit.userName = [PListData objectAtIndex:i];
twit.displayName = [dict objectAtIndex:@”name”];
twit.profileImageURL = [dict objectAtIndex:@”profile_image_url”];
[personList addObject:person];

and then

twit = [personList objectAtIndex:[indexPath row]];
NSURL *imageURL = [NSURL URLWithString:twit.personImage];
NSData *data = [NSData dataWithContentsOfURL:imageURL];
cell.imageView.image = [UIImage imageWithData:data];
cell.text = twit.displayName;
return cell;

SCENARIO 2

cell.labelText.text = [persons objectAtIndex:indexPath.row];

Ok this is because in the first code we create the person objects, place them into the array and release the person object (twit).  We later call that same array, use it to fill the twit object again and voila.  In the second code, we use the array directly after having created it from the person object (twit).

4.  Does anyone know if i can make Xcode highlight in background colors
the different code blocks?  For example, add red background from –
(void)viewDidLoad to the end of it; and then blue background color to
the next method and so on?

Ive seen the sidebars that highlight but theyre not very helpful,
specially when you print.

I did find out that you can select a complete {} function by double clicking the ending }.  But it only works on-screen.  I wish they came up with a background coloring scheme for when you print.

Presence 2 Stanford CS193P Strategy

CONCEPTUALLY speaking, we must read the dictionary objects, therefore getting the users name and use it to:
1. populate our Person Object
2. get the count value to set the number of Rows in Section
3. set the cell values to the names of these guys.

So far Ive:

1. gotten the filepath
2. check if exists and create array for count
3. initwithdictionary with object@index:count
4. create Person Class Instance alloc/init
5. set my Persons displayName, userName & imageURL to the data from the dictionary on twitter via fetchusername.
6. now i have a person object with 3 usernames. i need the count to set the number of rowsinsection. i tried using my array for the plist file count defined above but i get an error saying its undeclared in that function because i declared it in the viewDidLoad. so do i need to declare it again? – i had to dump the person object into an array and then get it back out again.

Memory Management Stanford CS193P iPhone Dev

Im not so clear on memory management; i understand what you create you must release, ok, but when?!  Because i just saw the MyTabBar example which creates ViewControllers, 3 of them i think, programatically, and a few lines down in the same m file, the delegate, the controllers get released.  Release means they get destroyed right?  I guess im not understanding conceptually what actually happens because to me, if you create in line 10 and release in line 20, even saying it sounds stupid to me, but its what i see, the user wont have time to use it :).

Or is it because they get created, then added to a new object, the tabbarcontroller, and therefore the individual instances created can be released because they are now part of the tabbarcontroller object which will be released some other time?