开发者

Use of nested references in objective C

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜