How to declare NSString constants for passing to NSNotificationCenter

Posted by synic on Stack Overflow See other posts from Stack Overflow or by synic
Published on 2010-05-27T01:29:19Z Indexed on 2010/05/27 1:31 UTC
Read the original article Hit count: 394

Filed under:
|

I've got the following in my .h file:

#ifndef _BALANCE_NOTIFICATION
#define _BALANCE NOTIFICATION
const NSString *BalanceUpdateNotification
#endif

and the following in my .m file:

const NSString *BalanceUpdateNotification = @"BalanceUpdateNotification";

I'm using this with the following codes:

[[NSNotificationCenter defaultCenter]
    addObserver:self
    selector:@selector(updateBalance:)
    name:BalanceUpdateNotification
    object:nil];

and

[[NSNotificatoinCenter defaultCenter]
    postNotificationName:BalanceUpdateNotificatoin
    object:self userInfo:nil];

Which works, but it gives me a warning:

Passing argument 1 of 'postNotificationName:object:userInfo' discards qualifiers from pointer target type

So, I can cast it to (NSString *), but I'm wondering what the proper way to do this is.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk