• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Guidance for learner
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Guidance for learner
      • From: Ricky Sharp <email@hidden>
References: 
 >Guidance for learner (From: "Barry" <email@hidden>)
 >Re: Guidance for learner (From: "Alan Smith" <email@hidden>)
 >Re: Guidance for learner (From: Brian Smith <email@hidden>)

  • Prev by Date: Re: Play a song with QTMovie
  • Next by Date: Re: Play a song with QTMovie
  • Previous by thread: Re: Guidance for learner
  • Next by thread: Re: Guidance for learner
  • Index(es):
    • Date
    • Thread