[MonoTouch] NSNotificationCenter Warning

Jeff Stedfast jeff at xamarin.com
Tue Oct 4 15:08:13 EDT 2011


Hi Andrew,

Okay, now that I've looked at the code I think I know why. I was confused
before and thought the NSString variant was deprecated and the string
variant was the recommended version (but it's the opposite).

There are a few reasons for this change:

1. Some users of this API will compare pointers instead of strcmp()ing the
contents of the string which means that things might not work (depending on
the underlying implementation) with the 'string' API.
2. it encourages the use of string constants provided by the APIs
3. less overhead; no need to convert from string to NSString (which involves
an alloc + UTF-16->UTF-8 conversion)

Note that the 'string' version will continue to work in all the same places
it used to work before - it's just that it will have (slightly) more
overhead and isn't guaranteed to work if the underlying string comparers use
pointer comparisons instead of content comparisons.

Hope that helps,

Jeff

On Tue, Oct 4, 2011 at 1:39 PM, ayoung <andrewdyoung at gmail.com> wrote:

> Thanks Jeff and Dimitris.
>
> Jeff, yes, I am curious as to why the former is obsolete.
>
> On Tuesday, October 4, 2011 at 10:36, Jeff Stedfast [via MonoTouch] wrote:
>
>  Hi ANdrew,
>
> The difference seems to be string vs NSString (I missed it the first time I
> looked at it too).
>
> I'm not sure why the old way was obsoleted, though. I could ask around if
> you want...
>
> Hope that helps,
>
> Jeff
>
> On Tue, Oct 4, 2011 at 1:33 PM, Andrew Young <[hidden email]<http://user/SendEmail.jtp?type=node&node=3871764&i=0>
> > wrote:
>
>  Why am I getting this warning?
>
> "Warning CS0618:
> `MonoTouch.Foundation.NSNotificationCenter.AddObserver(string,
> System.Action<MonoTouch.Foundation.NSNotification>)' is obsolete: `Use
> AddObserver(NSSstring, Action<NSNotification>) instead'"
>
> I don't see the difference between the two calls. The only difference is
> that the former is fully namespaced. The latter is not. Please tell me I'm
> wrong.
>
> _______________________________________________
> MonoTouch mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=3871764&i=1>
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
>
> _______________________________________________
> MonoTouch mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=3871764&i=2>
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://monotouch.2284126.n4.nabble.com/NSNotificationCenter-Warning-tp3871752p3871764.html
>  To start a new topic under MonoTouch, email [hidden email]<http://user/SendEmail.jtp?type=node&node=3871773&i=0>
> To unsubscribe from MonoTouch, click here.
>
>
>
> ------------------------------
> View this message in context: Re: NSNotificationCenter Warning<http://monotouch.2284126.n4.nabble.com/NSNotificationCenter-Warning-tp3871752p3871773.html>
> Sent from the MonoTouch mailing list archive<http://monotouch.2284126.n4.nabble.com/>at Nabble.com.
>
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20111004/cc66252a/attachment-0001.html 


More information about the MonoTouch mailing list