Re: Objects Not being added to array
Re: Objects Not being added to array
- Subject: Re: Objects Not being added to array
- From: Nick Zitzmann <email@hidden>
- Date: Sat, 16 Dec 2006 22:45:18 -0700
On Dec 16, 2006, at 9:23 PM, Matthew Callis wrote:
NSString *cur_artist = [[allTapes objectAtIndex:0]
objectAtIndex:0];
NSString *cur_venue = [[allTapes objectAtIndex:0]
objectAtIndex:1];
NSString *cur_location = [[allTapes objectAtIndex:0]
objectAtIndex:2];
NSString *cur_genre = [[allTapes objectAtIndex:0]
objectAtIndex:3];
NSString *cur_year = [[allTapes objectAtIndex:0]
objectAtIndex:4];
A little bit of advice: It's a better idea to use keyed objects in
this case instead of putting arrays inside of arrays. Not only is it
less messy, but if something changes and the object count is
different, or some objects become optional, then you won't have to
make any changes here.
int *cur_length = 0;
int *cur_count = 0;
These should not be pointers.
NSArrayController * tapeBunch = [[[NSArrayController alloc] init]
retain];
tapeBunch = [[tapeBunch retain] autorelease];
This code here will leak memory, since you're retaining an object
three times and autoreleasing it once. Moreover, you don't need to
use NSArrayController. Since you're just getting the array object
later on, you should use NSMutableArray directly.
for(i = 0; i < [allTapes count]; i++){
Here you're calling [allTapes count] on every trip through the loop.
Unless allTapes is being changed in the loop (and it isn't), you
should set [allTapes count] to a constant and use that instead.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden