Newbie Question (alloc, init, retain?)
Newbie Question (alloc, init, retain?)
- Subject: Newbie Question (alloc, init, retain?)
- From: Rob Cohen <email@hidden>
- Date: Wed, 28 May 2003 09:10:22 -0400
I've been reading the list for a long time and now I've started something
that has prompted a question.
I had an idea for a very simple app to use as a learning exercise. My app
is a one column table that the user types numbers into and the mean average
is calculated as the user types in new numbers.
My question is about memory management and object allocation and
initialization. When a number gets added, I add an NSNumber set to 0.0 to
an NSMutuableArray, something like this:
NSNumber *foo;
foo = [NSNumber numberWithFloat:0.0];
[Numbers insertObject:foo atIndex:[Numbers count]];
[theTableView reloadData];
Do I have to send [[foo alloc] init]? How do I know which classes need this
message?
Also since I just add the object to the array, do I need to send [foo
retain]?
Thanks for any help. The light bulb just hasn't gone on yet.
-R
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.