Re: Guidance for learner
Re: Guidance for learner
- Subject: Re: Guidance for learner
- From: "Alan Smith" <email@hidden>
- Date: Tue, 26 Jun 2007 18:31:29 -0400
Brian,
You're absolutely right! I forgot to put the [data release] in there!
The for loop should be the below and *not* what I originally posted.
for (i = 0; i < 7; i++)
{
NSString *filePath = [NSString stringWithFormat: @"%@/5a_d.w6s",
appDirectory, i];
NSData *data = [[NSData alloc] initWithContentsOfFile: filePath];
files addObject: data];
[data release];
}
The reason I didn't use +[NSData dataWithContentsOfFile:] is because
the returned object is autoreleased and won't be released as fast as
if you release it specifically when done with it. To perfect the above
a little more you could do it lie so:
for (i = 0; i < 7; i++)
{
NSString *filePath = [[NSString alloc] initWithFormat:
@"%@/5a_d.w6s", appDirectory, i];
NSData *data = [[NSData alloc] initWithContentsOfFile: filePath];
files addObject: data];
[filePath release];
[data release];
}
Peace, Alan
--
// Quotes from Alan Smith -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that personal beliefs are not something to
argue or fight over, it shall evolve."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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