EXC_BAD 使用自己的结构作为返回值
我使用以下结构作为方法的返回值:
typedef struct {
CLLocationCoordinate2D topLeftCorner;
CLLocationCoordinate2D bottomRightCorner;
} LCMapBoundings;
以下方法立即崩溃:
-(LCMapBoundings)calculate {
NSLog(@"test");
}
但是那个可以工作:
-(LCMapBoundings*)calculate {
NSLog(@"test");
}
为什么会这样?使用第一种方法时我搞砸了什么?
i am using the following struct as a return value of a method:
typedef struct {
CLLocationCoordinate2D topLeftCorner;
CLLocationCoordinate2D bottomRightCorner;
} LCMapBoundings;
The following method crashes instantly:
-(LCMapBoundings)calculate {
NSLog(@"test");
}
But that one works:
-(LCMapBoundings*)calculate {
NSLog(@"test");
}
Why is that? What am i messing up when using the first method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许它崩溃是因为您没有在方法中返回值?这是未定义的行为。
Perhaps it's crashing because you don't return a value in your method? That's undefined behaviour.