[NSMutableString string] 与 [[NSMutableString string] autorelease] 相同吗?
我注意到某处有一段代码 NSMutableString *myString = [[NSMutableString string] autorelease];
是不是太过分了?它不应该和 [NSMutableString string] 一样吗?
I noticed a piece of code somewhere it does
NSMutableString *myString = [[NSMutableString string] autorelease];
Is it overkill? Shouldn't it be the same as [NSMutableString string]?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果他们不在其他地方调用保留,将导致崩溃。
是一样的
will lead to a crash if they aren't calling retain on it elsewhere.
is the same as
我觉得不太对劲。您确定您看到的示例实际上是这样做的吗?
[NSMutableString string]
相当于因此,根据您提供的示例,您将得到
这将导致过度释放和
exc_bad_access
错误。Doesn't look right to me. Are you sure that the example you saw is actually doing this?
[NSMutableString string]
is equivalent toSo with the example you provided, you would get
which would result in an over release and an
exc_bad_access
error.