开发者

Use of nested references in objective C

开发者 https://www.devze.com 2022-12-17 05:40 出处:网络
Getting an error mess开发者_JAVA技巧age \"Nested functions are disabled, use -fnested\" etc in XCode/ObjC.

Getting an error mess开发者_JAVA技巧age "Nested functions are disabled, use -fnested" etc in XCode/ObjC.

Here's the code (balls is an NSMutableArray pointing at a bunch of UIViews).

CGPoint pos=[[self.balls objectAtIndex:pointidx] center];

But the following seems to compile ok.

UIView *ref=[self.balls objectAtIndex:pointidx];
CGPoint pos=ref.center;

Should I use "-fnested-functions to re-enable (and if so where do I put the "-fnested-functions")? Or should I just put up with additional step of creating a UIView* pointer first? ty.


Generally when you see nested functions warnings, what you really have is a syntax error.

Is pointidx an integer and balls an NSArray? Also, do you have a property for balls? Try just balls instead of self.balls.

Edit: Since it's a compile time thing, I'm thinking maybe it doesn't like passing center to NSObject. What happens if you cast the object:

CGPoint pos=[(UIView *)([self.balls objectAtIndex:pointidx]) center];

Irrelevant musing obfuscated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号