• 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: notifications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: notifications


  • Subject: Re: notifications
  • From: Jonathon Mah <email@hidden>
  • Date: Tue, 22 May 2007 00:34:23 +0930

Hy julien,

On 2007-05-21, at 23:54, julien ricard wrote:

What's the best way to get the notification from the iTunesConnection
object within the controller class?

Use bindings. You can either set it up in Interface Builder, or do it in code:


- (void)awakeFromNib
{
    iTunesConnection *connection = [[iTunesConnection alloc] init];
#warning Leaking connection
    [currentTrackField bind:@"value"
                   toObject:connection
                withKeyPath:@"currentTrack"
                    options:0];
}


Also, unless you're writing this for Leopard, your code has absolutely no memory management. It will not take kindly to that. There is plenty of good documentation around on that, so I won't make a sub-par effort here.


@interface iTunesConnection : NSObject
{
   NSString *currentTrack;
}
- (id) init;
- (void) updateNow:(NSNotification *)notification;
- (void) updateCurrentTrackName;
- (NSString *) getcurrentTrack;
- (void) setCurrentTrack:(NSString *) curTrack;

@end

Change the name of -getcurrentTrack to -currentTrack. "The 'get' prefix has a very specific meaning in Cocoa-derived APIs: It means that you're going to be passing in a location by reference where the result should be stored." -- Chris Hanson



Have fun,



Jonathon Mah
email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >notifications (From: "julien ricard" <email@hidden>)

  • Prev by Date: Re: Encoding infinite loops
  • Next by Date: Re: Encoding infinite loops
  • Previous by thread: notifications
  • Next by thread: Re: notifications
  • Index(es):
    • Date
    • Thread