• 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 06:57:58 -0400

Barry,

I suggest reading the linked web pages to learn about memory management:

http://www.stepwise.com/Articles/Technical/2001-03-11.01.html
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html

Below is code that I would use to do the same thing.

- (id)init
{
 if ((self = [super init]) != nil)
 {
   [self setDelegate: self];

   // This should be replaced with a 'singleton' class. Google it.
   [[ImageDocController alloc] init];

   NSMutableArray *files = [[NSMutableArray alloc] init];
   NSString *appDirectory = [[[NSBundle mainBundle] bundlePath]
stringByDeletingLastPathComponent];

   int i;

   for (i = 0; i < 7; i++)
   {
       NSString *filePath = [NSString stringWithFormat:
@"%@/5a_d.w6s", appDirectory, i];
       NSData *data = [[NSData alloc] initWithContentsOfFile: filePath];

       [files addObject: data];
   }

   dataFiles = [[NSArray alloc] initWithArray: files];

   [files release];
 }

 return self;
}

@interface ImageApp : NSApplication
{
       NSArray *dataFiles;
}
@end

Note that I haven't run this code, I wrote it in Safari.

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: "Barry" <email@hidden>
    • Re: Guidance for learner
      • From: Brian Smith <email@hidden>
References: 
 >Guidance for learner (From: "Barry" <email@hidden>)

  • Prev by Date: Re: Plugins and shared code question.,
  • Next by Date: Re: ObjC 3D engine
  • Previous by thread: Guidance for learner
  • Next by thread: Re: Guidance for learner
  • Index(es):
    • Date
    • Thread