Arc: Switch case is in protected scope
Arc: Switch case is in protected scope
- Subject: Arc: Switch case is in protected scope
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Tue, 22 Oct 2013 14:41:10 +0700
Converting to Arc (Xcode 5.0).
This works fine without Arc (regardless whether TRIGGER_ERROR is defined or not):
NSMutableString *mus = [ NSMutableString string ];
NSString *word = @"abc";
switch( self.colourType )
{
case colour_link:
[ mus appendString: @"<a href=\"" ];
#define TRIGGER_ERROR
#ifdef TRIGGER_ERROR
NSString *urlStr = [ word stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding ];
[ mus appendString: urlStr ];
#else // no_ERROR
[ mus appendString: [ word stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding ] ];
#endif // no_ERROR
break;
default:
[ mus appendString: word ];
};
But with Arc, if TRIGGER_ERROR is defined, I get an error: "Switch case is in protected scope" with the further explanation: "Jump bypasses initialization of retaining variable".
Was the old (non-arc) code faulty (but the compiler did not notice this)?
Why is the arc-version (with TRIGGER_ERROR defined) wrong?
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