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:


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;


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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s