xcode JSONKit 实现上的错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10010641/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Errors on JSONKit implement
提问by SnK
Upon importing the JSONKit.hand JSONKit.mfiles into my project , i get the following errors. I have browsed and browsed but none seems to have encountered these problems ?
将JSONKit.h和 JSONKit.m文件导入我的项目后,出现以下错误。我浏览和浏览过,但似乎没有人遇到过这些问题?
All i did was import the files and build and then i get this
我所做的只是导入文件并构建,然后我得到了这个
Is it something i forgot to import or ...??????
是我忘记导入还是......????
回答by tangqiaoboy
You can disable ARC(automatic reference count) in JSONKit files.
您可以在 JSONKit 文件中禁用 ARC(自动引用计数)。
Generally step is :
一般步骤是:
- Go to your project settings, under Build Phases > Compile Sources
- Select the files you want ARC disabled and add -fno-objc-arc compiler flags. You can set flags for multiple files in one shot by selecting the files then hitting "Enter" key.
- 转到您的项目设置,在 Build Phases > Compile Sources 下
- 选择要禁用 ARC 的文件并添加 -fno-objc-arc 编译器标志。您可以通过选择文件然后按“Enter”键,一次性为多个文件设置标志。
Please refer to this post: iOS 5 Best Practice (Release/retain?)for more details.
请参阅这篇文章:iOS 5 最佳实践(发布/保留?)了解更多详情。
Hope it helps.
希望能帮助到你。
Edit
编辑
After discussion, we also have some other options to solve the problem. For example, you can convert JSONKit to ARC compatible. But according to Mike Weller
's statement, it will be very hard to convert because JSONKit uses malloc
to manage memory.
经过讨论,我们还有一些其他的选择来解决这个问题。例如,您可以将 JSONKit 转换为兼容 ARC。但是根据Mike Weller
的说法,转换起来会非常困难,因为 JSONKit 是malloc
用来管理内存的。
I think use -fno-objc-arc
compiler flag is a low-risk and convenient way to solve the problem.
我认为使用-fno-objc-arc
编译器标志是一种低风险且方便的解决问题的方法。
回答by Zalykr
tangqiaoboy's answer will resolve those errors but you can also consider using the class NSJSONSerialization. It makes it really easy do convert NSDictionarys and NSArrays to JSON and vice-versa.
tangqiaoboy 的回答将解决这些错误,但您也可以考虑使用类 NSJSONSerialization。它使得将 NSDictionarys 和 NSArrays 转换为 JSON 非常容易,反之亦然。
Good luck!
祝你好运!
回答by Devang
You can convert your project into ARC
compatible, by following steps
您可以ARC
通过以下步骤将您的项目转换为兼容项目
Go to Edit menu -> Refactor -> Convert to Objective-C ARC...
去 Edit menu -> Refactor -> Convert to Objective-C ARC...
Or If you do not
want to use ARC
in your current project then follow tangqiaoboy
's steps.
或者,如果您do not
想ARC
在当前项目中使用,请按照tangqiaoboy
的步骤操作。