可可与可可接触-有什么区别? [英] Cocoa versus Cocoa Touch - What is the difference?

查看:86
本文介绍了可可与可可接触-有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Objective-C学习iOS开发,并且发现了很多代码示例.

I am learning iOS development in Objective-C, and I have found a lot of code examples.

其中有些人说它们仅适用于Mac OS X(不适用于iOS).

Some of them, though, say that they are only for Mac OS X (not iOS).

有人可以向我解释一下Cocoa和Cocoa Touch(在库级别)有什么区别,以便我知道什么代码将起作用,什么将不起作用吗?

Can someone please explain to me what is the difference between Cocoa and Cocoa Touch (at a library level), so that I know what code will work and what will not work?

推荐答案

Cocoa通常被称为Foundation和AppKit框架的组合,而Cocoa Touch是Foundation和UIKit框架的组合.

Cocoa is commonly referred to as the combination of the Foundation and AppKit frameworks, while Cocoa Touch is the combination of the Foundation and UIKit frameworks.

Cocoa和Cocoa Touch位于其他框架集合的顶部,以创建API堆栈.其他层是媒体,核心服务和核心操作系统.

Cocoa and Cocoa Touch sit on top of other collections of frameworks to create the API stacks. The other layers are Media, Core Services and Core OS.

Cocoa和Cocoa touch之间的主要区别在于UI类和API与Mac OS X和macOS并不相同,因此您具有UITextField而不是NSTextField.许多类共享相同的功能,并且只需更改类名即可轻松移植,尽管大多数都需要进行更多更改,但通常不会太繁琐.

The main difference between Cocoa and Cocoa touch is that the UI classes and APIs aren't the same as Mac OS X’s and macOS’s, so instead of NSTextField, you have UITextField. Many of the classes share the same functionality and can be ported quite easily by simply changing the class name, though most will require some more changes, but usually nothing too heavy.

Cocoa和Cocoa Touch中的Foundation框架之间也存在一些差异,最常见的类是缺少,例如,Cocoa具有NSHost而Cocoa Touch没有.

There are also some differences between the Foundation frameworks in Cocoa and Cocoa Touch, most commonly missing classes, for example, Cocoa has NSHost and Cocoa Touch doesn't.

您将了解到两者之间的更多细微差别,并且很快就能凭直觉知道在iPhone上进行很少修改/无需修改的工作原理,以及需要做些什么工作才能在iPhone之间进行移植的方法,但这并不是那么困难.

You will come to know more of the nuances between the two and will soon be able to instinctively know what will work on an iPhone with little/no modification and what will require some work to port between, but it's not that difficult.

这篇关于可可与可可接触-有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆