Re: Guidance for learner
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