Objective-C,命令行项目的 Web 服务框架
我正在用 Objective-C 编写脚本。 我在 xcode 中创建了一个“命令行工具”,我想请求一个 JSON Web 服务。
在我以前的 iPhone 应用程序中,我使用导入 ASIHTTPRequest 框架。不幸的是这个框架使用 UIKit 库。
我不想导入这个库和所有这些依赖项。
您知道我可以在命令行工具应用程序中使用的好框架或库吗?
谢谢。
I'm working on the script in objective-c.
I created a "Command Line Tool" in xcode and I want to request a JSON web service.
In my previous iPhone apps I use to import ASIHTTPRequest framework. Unfortunetly this framework use UIKit library.
I don't want to import this library and all these dependencies.
Do you know a good framework or library that I can use in my Command Line Tool application ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ASIHTTPRequest 不应该需要 UIKit。如果存在的话,您应该能够将其删除。无论如何,您无法将 UIKit 导入 Mac 应用程序。
不过,ASI 框架已停止使用。您可能想查看其他选项,例如 MKNetworkKit 和 AFNetworking。两者都应该在命令行应用程序中正常工作。
编辑:不要忘记大多数像这样的框架都需要运行循环。在命令行应用程序中管理它的典型方法如下所示(来自 NSRunLoop 文档):
这是一个无限循环,直到设置
shouldKeepRunning
。您还可以使用
NSApplication
,如 在 Cocoa 中运行 NSRunLoop 所示命令行程序。ASIHTTPRequest shouldn't require UIKit. You should be able to remove that if it's there. You can't import UIKit into a Mac app anyway.
The ASI framework has been discontinued, though. You may want to look at other options such as MKNetworkKit and AFNetworking. Both should work fine in a commandline app.
EDIT: Don't forget that most frameworks like this will require a run loop. The typical way to manage that in a commandline app looks like this (from NSRunLoop docs):
This is an infinite loop until something sets
shouldKeepRunning
.You can also use
NSApplication
as shown in Run NSRunLoop in a Cocoa command-line program.您可以在命令行工具中使用 ASIHTTPRequest。
有关示例,请随意查看我在 github 上提供的
pinch-objc
项目。请参阅zipcommander
项目。https://github.com/epatel/pinch-objc
You can use ASIHTTPRequest in a command line tool.
For an example feel free to look at my
pinch-objc
project available at github. See thezipcommander
project.https://github.com/epatel/pinch-objc