Class Factory Methods?
Class Factory Methods?
- Subject: Class Factory Methods?
- From: Chunk 1978 <email@hidden>
- Date: Mon, 22 Jun 2009 15:02:05 -0400
confused (seriously, what else is new?)... correct me if (where) i'm wrong:
-=-=-=-=-
-(void)myMethod
{
NSString *foo = [[NSString alloc] initWithFormat:@"bar"];
NSLog(foo);
}
-=-=-=-=-
"new", "alloc", initWithFormat" (or "stringWithFormat") are class
factory methods that are declared methods inherited by my custom
classes, i guess somewhere in NSObject?
so it write a stringWIthFormat class method, i guess to override it
for the custome class it's written within:
-=-=-=-=-
+ (NSString *)stringWithFormat
{
return @"newBar";
}
-=-=-=-=-
assuming both these methods are written in the same custom class, does
that mean that my first method "(void)myMethod" will not allocate and
initiate a new stringWithFormat of @"bar" and output it to the console
with NSLog(), but will output @"newBar" to the console?
_______________________________________________
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