• 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: Newbie: applescript "call method" to obj-c method (booleans & image data)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie: applescript "call method" to obj-c method (booleans & image data)


  • Subject: Re: Newbie: applescript "call method" to obj-c method (booleans & image data)
  • From: Graham Cox <email@hidden>
  • Date: Sun, 15 Jun 2008 02:17:19 +1000


On 15 Jun 2008, at 2:08 am, Loren Ryter wrote:

WithSticky:(BOOL *)aStick WithClick:(NSString *)aClick


BOOL* means "pointer to BOOL" not BOOL itself. So you need to remove the *. The same doesn't apply to NSNumber because NSNumber is an object (objects are always passed by pointer). If you wanted to use an NSNumber (there's no real reason to here though) you can extract the actual bool using -[number boolValue];

iconData:[NSImage initWithContentsOfFile:aPath]

should be iconData:[[[NSImage alloc] initWithContentsOfFile:path] autorelease]



there are two kinds of methods - class methods and instance methods. Class methods can be sent like [NSImage ...], but instance methods have to be sent to an actual object. In the headers, the two kinds of methods are distinguished by the + and - signs in front of them, + for class methods, - for instance methods. Because - initWithContentsOfFile: is an instance method, you have to alloc an instance and then arrange for it to be released later - which is what the corrected line above does.


hth,

Graham
_______________________________________________

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: Newbie: applescript "call method" to obj-c method (booleans & image data)
      • From: Loren Ryter <email@hidden>
References: 
 >Newbie: applescript "call method" to obj-c method (booleans & image data) (From: Loren Ryter <email@hidden>)

  • Prev by Date: Newbie: applescript "call method" to obj-c method (booleans & image data)
  • Next by Date: Re: Newbie: applescript "call method" to obj-c method (booleans & image data)
  • Previous by thread: Newbie: applescript "call method" to obj-c method (booleans & image data)
  • Next by thread: Re: Newbie: applescript "call method" to obj-c method (booleans & image data)
  • Index(es):
    • Date
    • Thread