• 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
Class Factory Methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Class Factory Methods?
      • From: "I. Savant" <email@hidden>
    • Re: Class Factory Methods?
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Approaches for this Matching Problem?
  • Next by Date: Re: Class Factory Methods?
  • Previous by thread: How do I sync Quartz drawing-path coordinates with the physical iPhone UIView coordinates?
  • Next by thread: Re: Class Factory Methods?
  • Index(es):
    • Date
    • Thread