apache 使用objective-c进行Web应用程序编程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1519324/
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
Web application programming using objective-c?
提问by Jacob
Just say you have a quite large and complicated desktop application written in objective-c/cocoa written properly in MVC. You then wish to replace the V and C so that it is a web application?
只是说你有一个相当大和复杂的桌面应用程序,用 Objective-c/cocoa 编写,在 MVC 中正确编写。然后您希望替换 V 和 C 使其成为 Web 应用程序?
Is there anything like Tomcat but for objective c? The closest thing I can think of is somehow convert the Model code into an apache module to load in apache?
除了目标 c 之外,还有没有像 Tomcat 一样的东西?我能想到的最接近的事情是以某种方式将模型代码转换为 apache 模块以加载到 apache 中?
Obviously I could embed some sort of HTTP server and write a whole pile of code to manage sessions and requests and responses and so on, but might there be a simpler way?
显然我可以嵌入某种 HTTP 服务器并编写一大堆代码来管理会话、请求和响应等,但可能有更简单的方法吗?
回答by Georg Sch?lly
You can leave the server almost as-is. I'd run it as a daemon in the background.
您可以几乎保持原样离开服务器。我会在后台将它作为守护进程运行。
I'd split the controller part. One part of it resides on the server as a connection between HTTP requests and the daemon.
我会拆分控制器部分。它的一部分驻留在服务器上,作为 HTTP 请求和守护程序之间的连接。
- You could run a self-made http server.
- You could build it into a Apache module as you mentioned.
- You could access your controller through CGI. This is the easiest option as I see it.
- 你可以运行一个自制的http服务器。
- 您可以将它构建到您提到的 Apache 模块中。
- 您可以通过 CGI 访问您的控制器。在我看来,这是最简单的选择。
The second part of the controller is written in Javascript in the browser, exchanging data with the server and updating the GUI.
控制器的第二部分在浏览器中用 Javascript 编写,与服务器交换数据并更新 GUI。
The view part is written completely in javascript.
视图部分完全用 javascript 编写。
You could - if you want - leave out the controller on the server and make the model understand HTTP requests.
For the Controller / View part consider using a framework.
- jQueryfor only a light interface. (Or a similar framework.)
- I haven't yet found a framework that leaves all the model stuff to the server. Maybe you can use SproutCore or Cappuccino accordingly.
- SproutCore, the full-backed MVC framework that is used by Apple. (Think so at least.)
- Cappuccino, another full-backed MVC framework.
您可以 - 如果需要 - 在服务器上省略控制器并使模型理解 HTTP 请求。
对于控制器/视图部分,请考虑使用框架。
- jQuery仅用于轻量级界面。(或类似的框架。)
- 我还没有找到将所有模型内容都留给服务器的框架。也许您可以相应地使用 SproutCore 或 Cappuccino。
- SproutCore,Apple 使用的全支持 MVC 框架。(至少这么认为。)
- Cappuccino,另一个全支持的 MVC 框架。
回答by Georg Sch?lly
Have you looked at Cappuccino? http://cappuccino.org/
你看过卡布奇诺吗? http://cappuccino.org/
I have not used but have heard many good things about it.
我没有使用过,但听说过很多关于它的好东西。
回答by Loki
There is a new web development platform for Objective-C/Cocoa called Bombax. It sounds like exactly what you're looking for (it is designed to allow you to write entire web applications in Objective-C). Perhaps you could even combine it with Cappuccino. You can check it out at http://www.bombaxtic.com.
Objective-C/Cocoa 有一个新的 Web 开发平台,称为 Bombax。这听起来正是您要寻找的(它旨在允许您用 Objective-C 编写整个 Web 应用程序)。也许你甚至可以将它与卡布奇诺结合起来。您可以在http://www.bombaxtic.com 上查看。
回答by codecowboy
There is Frothkit - http://code.google.com/p/frothkit/but it appears not to have been updated for a year.
有 Frothkit - http://code.google.com/p/frothkit/但它似乎没有更新一年。
回答by Shawn Craver
The closest you'll probably come to Objective-C web frameworks are either SOPE, or GNUStep, neither of which I have used, but ran across when I was deciding if I wanted to use Rails or something written in Objective-C for my web stuff. There's also ARJDatabase, which is kind of like Core Data, but not source compatible.
您可能最接近 Objective-C 网络框架的是SOPE或GNUStep,我都没有使用过这两个框架,但是当我决定是否要使用 Rails 或用 Objective-C 编写的东西用于我的网络时遇到了东西。还有ARJDatabase,它有点像 Core Data,但不兼容源代码。
The bottom line is, unless you were very careful about how you wrote your code (i.e. wrote it with GNUStep in mind, didn't use anything Apple specific) you're probably going to have to do quite a bit of work anyway. And if you used Core Data at all, there's no way I know of to reuse that outside of a Mac App. And since it's not setup to be used my multiple simultaneous users, you wouldn't want to use that in a web app anyway. Bottom line, I went with Rails.
最重要的是,除非您非常小心地编写代码(即考虑到 GNUStep 编写代码,没有使用 Apple 特定的任何内容),否则您可能需要做很多工作。而且,如果您完全使用 Core Data,我知道无法在 Mac 应用程序之外重用它。而且由于它没有设置为供我的多个同时使用的用户使用,因此无论如何您都不想在网络应用程序中使用它。最重要的是,我选择了 Rails。

