---------- Forwarded message ----------
From: *SevenBits* <sevenbitst...@gmail.com>
Date: Thursday, January 1, 2015
Subject: Application Crashing Under Mavericks, but not Yosemite
(Entitlements Issue?)
To: Uli Kusterer <witness.of.teacht...@gmx.net>


On Thursday, January 1, 2015, Uli Kusterer <witness.of.teacht...@gmx.net
<javascript:_e(%7B%7D,'cvml','witness.of.teacht...@gmx.net');>> wrote:

> On 01 Jan 2015, at 02:50, Jack Brindle <jackbrin...@me.com> wrote:
> > You might want to extend that. The header file indicates that
> containsString: _only_ is available in OS X starting with 10.10 and iOS
> starting with 8.0. I would expect this to crash, or at least behave very
> poorly, under any prior OS since the call simply doesn’t exist there.
> >
> > Interesting that the only place it appears to be documented by Apple is
> in the header file. It is widely “documented” at various web sites, but
> using any call based on that is definitely rolling the dice. The central
> rule is that if you are releasing code for others to run, be sure to use
> calls that Apple documents to be available for the earliest targeted OS.
> >
> > I’d replace it with a more suitable call, which appears to be
> rangeOfString:options: The header file indicates it should be called with
> no options. in fact you probably should read the NSString header file info
> for that call. It is somewhat interesting.
>
>  A good workaround is probably to create your own equivalent call with an
> identical signature in a category and just replace all calls to
> containsString with that:
>
> @implementation NSString (SBContainsStringBackwardsCompat)
>
> -(BOOL) sb_containsString: (NSString*)inString
> {
>         return [self rangeOfString: inString options: 0].location !=
> NSNotFound;
> }
>
> @end
>
> (Warning: code written in mail, never compiled) Then, when your baseline
> rises to 10.10, you can just do a search-and-replace of sb_containsString:
> to containsString:.


I never even realized that you guys had resumed this thread. Sorry for not
piping in.

Yeah, that ultimately was my problem. I have a category like what you
describe, because I had begun writing my code on 10.9, but I had forgotten
to use it when coding with the 10.10 SDK when I upgraded to Yosemite.
Because the call is present on that OS version, there was no crash there
and so I did not suspect that there were issues. I've refactored the code
to change all calls over to my category, which solved this problem.

The futile aspect of all this is that containsString: is never mentioned in
the NSString documentation, so I never knew that it had been added in
Yosemite. (Why can't all of the new stuff be in the documentation? It seems
like quite a few properties and calls are missing...)

This is quite frustrating at times. Oh, well. Thanks for contributing, you
guys.

Uli: is it possible to create a category which defines a method called
containsString:, and only have it activate on 10.9 or lower and use the new
Apple method on 10.10 and above?


>
> Cheers,
> -- Uli Kusterer
> “The Witnesses of TeachText are everywhere...”
> http://zathras.de
>
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to