Objective-C,命令行项目的 Web 服务框架

发布于 2025-01-05 00:46:36 字数 217 浏览 3 评论 0原文

我正在用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空城之時有危險 2025-01-12 00:46:36

ASIHTTPRequest 不应该需要 UIKit。如果存在的话,您应该能够将其删除。无论如何,您无法将 UIKit 导入 Mac 应用程序。

不过,ASI 框架已停止使用。您可能想查看其他选项,例如 MKNetworkKitAFNetworking。两者都应该在命令行应用程序中正常工作。


编辑:不要忘记大多数像这样的框架都需要运行循环。在命令行应用程序中管理它的典型方法如下所示(来自 NSRunLoop 文档):

BOOL shouldKeepRunning = YES;        // global
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
while (shouldKeepRunning && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);

这是一个无限循环,直到设置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):

BOOL shouldKeepRunning = YES;        // global
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
while (shouldKeepRunning && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);

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.

三岁铭 2025-01-12 00:46:36

您可以在命令行工具中使用 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 the zipcommander project.

https://github.com/epatel/pinch-objc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文