Re: How to convert String.Index to UInt?
Re: How to convert String.Index to UInt?
- Subject: Re: How to convert String.Index to UInt?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Tue, 19 Aug 2014 16:06:39 +0700
On 18 Aug 2014, at 12:44, Quincey Morris <email@hidden> wrote:
> On Aug 17, 2014, at 21:36 , Gerriet M. Denkmann <email@hidden> wrote:
>
> Watching (so to speak) what you’re doing from a distance, what concerns me is *not* that you are or are not doing things in a swifty way, but that you’re *evaluating* Swift when it’s still in an incomplete form — unstable, under-documented, and under-implemented. I know you’ve said you’re “just” trying to learn the new language at this point, but I think there’s a danger that you’ll conclude that the new language is unusable (or incomprehensible, or something) *because of* its current incomplete form.
Well, if there are any issues with Swift (while still being in beta) they should be raised right now.
Changing them will be much more difficult later on.
Here some interesting links I just found:
<http://mjtsai.com/blog/2014/08/18/its-a-coup/>
<http://www.buckleyisms.com/home/2014/6/16/the-case-for-message-passing-in-swift.html>
<https://devforums.apple.com/message/992863#992863>
[ regarding performSelector: ]
>
> This particular issue isn’t Swift-related, but ARC-related.
>
> The value of ARC is that it preserves correctness (memory-management correctness, I mean) in source code that follows the ARC rules. Within the ARC domain — that is, if you write code according to the rules — you *cannot* have any memory management errors**. But you only get this happy outcome if you stay within the ARC domain. If you invoke code that doesn’t use ARC, or that ARC tells you is unsafe, then there is no guarantee of correctness. (Of course, your app may turn out to be correct if this non-ARC-domain code has no memory management bugs, but the correctness then comes from something outside of ARC’s purview.)
>
> The problem with ‘performSelector:’ is that it can break out of the ARC domain. Even if the invoking code uses ARC, and the performed code uses ARC, the transition between them isn’t necessarily correctness-preserving.
>
I use this:
NSString *aSelectorName = ...
SEL aSelector = NSSelectorFromString ( aSelectorName );
id a = [ self performSelector: aSelector ]; <-- PerformSelector may cause a leak because its selector is unknown
But what about:
SELPlus aSelector = BetterSelectorFromString ( aSelectorName, "returns object which does NOT need to be released" );
id a = [ self performSelector: aSelector ];
Or (if modifying SEL is not viable):
id a = [ self performSelector: aSelector withInfo: "returns object which does NOT need to be released" ]
This should work (as long as I do not lie about my selector), shouldn't it?
Kind regards,
Gerriet.
_______________________________________________
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