在考虑Objective-c中的“图书馆”时,我有什么想象?

时间:2023-02-02 22:26:47

For me, a library is a collection of classes that do useful things. Typically something, that can be useful in a lot of projects. Is that also the case in terms of objective-c? What exactly is a library there? Only classes that have methods? Or also collections of functions? And do they have to be compiled to be called a "library"? Where is the segregation between an "Framework"? Aren't bove the same thing?

对我来说,库是一组有用的类。通常是某些东西,可以在很多项目中使用。在Objective-c方面也是如此吗?那里的图书馆究竟是什么?只有拥有方法的类?还是功能集合?他们必须编译成一个“库”吗? “框架”之间的隔离在哪里?是不是同样的事情?

2 个解决方案

#1


According to Wikipedia: "Frameworks are functionally similar to shared libraries, a compiled object that can be dynamically loaded into a program's address space at runtime, but frameworks add associated resources, header files, and documentation."

根据*:“框架在功能上类似于共享库,一个编译对象,可以在运行时动态加载到程序的地址空间,但框架添加相关的资源,头文件和文档。”

A framework is essentially a shared library (binary, similar to a DLL) in a bundle that also includes all of the information needed to use that library (like header files, documentation, internationalization resources, etc). A framework without all of the extras is just a library.

框架本质上是一个包中的共享库(二进制文件,类似于DLL),它还包括使用该库所需的所有信息(如头文件,文档,国际化资源等)。没有所有附加功能的框架只是一个库。

There is no requirement that a framework be object-oriented in nature, though I assume that's the norm with Cocoa.

虽然我认为框架是Cocoa的标准,但并不要求框架本质上是面向对象的。

For Cocoa, the concept of a framework generally replaces (enhances) the concept of a library. However, the Objective-C toolchain imposes no such requirement. You can use source-only "libraries" or unix-style binary libraries (e.g. an .so file). I think of a "library" in these generic terms... it's just a collection of useful code, in source or binary form. A framework, on the other hand, is a specific thing with a specific meaning for OS X.

对于Cocoa,框架的概念通常取代(增强)库的概念。但是,Objective-C工具链没有强制要求。您可以使用仅源“库”或unix样式的二进制库(例如.so文件)。我想到了这些通用术语中的“库”......它只是源代码或二进制形式的有用代码集合。另一方面,框架是具有OS X特定含义的特定事物。

#2


Assuming you are talking about a library that uses the Cocoa frameworks and not just one written in the plain old Objective-C language, a library (or framework) is a collection of classes that work together to perform a specific task. I would not organize an ObjC framework as a collection of functions since that totally goes against the paradigm of the language.

假设您正在讨论使用Cocoa框架的库而不仅仅是使用普通的旧Objective-C语言编写的库,那么库(或框架)是一组一起工作以执行特定任务的类。我不会将ObjC框架组织为函数集合,因为这完全违背了该语言的范例。

As for the difference between a library and framework, that's probably a bit subjective. To me, a library (in the context of your question) is something written in C that probably more closely resembles a non-OO collection of functions. A framework would be a full package of classes as I described above. So the Messaging framework on CocoaDev would be a framework, whereas the sqlite3 APIs you can access on the iPhone would be a library. Again, that's just me. Other people may interpret the terms differently.

至于库和框架之间的区别,这可能有点主观。对我来说,一个库(在你的问题的上下文中)是用C编写的东西,可能更接近于非OO函数集合。如上所述,框架将是一个完整的类包。因此CocoaDev上的Messaging框架将是一个框架,而您可以在iPhone*问的sqlite3 API将是一个库。再一次,那只是我。其他人可能会不同地解释这些术语。

#1


According to Wikipedia: "Frameworks are functionally similar to shared libraries, a compiled object that can be dynamically loaded into a program's address space at runtime, but frameworks add associated resources, header files, and documentation."

根据*:“框架在功能上类似于共享库,一个编译对象,可以在运行时动态加载到程序的地址空间,但框架添加相关的资源,头文件和文档。”

A framework is essentially a shared library (binary, similar to a DLL) in a bundle that also includes all of the information needed to use that library (like header files, documentation, internationalization resources, etc). A framework without all of the extras is just a library.

框架本质上是一个包中的共享库(二进制文件,类似于DLL),它还包括使用该库所需的所有信息(如头文件,文档,国际化资源等)。没有所有附加功能的框架只是一个库。

There is no requirement that a framework be object-oriented in nature, though I assume that's the norm with Cocoa.

虽然我认为框架是Cocoa的标准,但并不要求框架本质上是面向对象的。

For Cocoa, the concept of a framework generally replaces (enhances) the concept of a library. However, the Objective-C toolchain imposes no such requirement. You can use source-only "libraries" or unix-style binary libraries (e.g. an .so file). I think of a "library" in these generic terms... it's just a collection of useful code, in source or binary form. A framework, on the other hand, is a specific thing with a specific meaning for OS X.

对于Cocoa,框架的概念通常取代(增强)库的概念。但是,Objective-C工具链没有强制要求。您可以使用仅源“库”或unix样式的二进制库(例如.so文件)。我想到了这些通用术语中的“库”......它只是源代码或二进制形式的有用代码集合。另一方面,框架是具有OS X特定含义的特定事物。

#2


Assuming you are talking about a library that uses the Cocoa frameworks and not just one written in the plain old Objective-C language, a library (or framework) is a collection of classes that work together to perform a specific task. I would not organize an ObjC framework as a collection of functions since that totally goes against the paradigm of the language.

假设您正在讨论使用Cocoa框架的库而不仅仅是使用普通的旧Objective-C语言编写的库,那么库(或框架)是一组一起工作以执行特定任务的类。我不会将ObjC框架组织为函数集合,因为这完全违背了该语言的范例。

As for the difference between a library and framework, that's probably a bit subjective. To me, a library (in the context of your question) is something written in C that probably more closely resembles a non-OO collection of functions. A framework would be a full package of classes as I described above. So the Messaging framework on CocoaDev would be a framework, whereas the sqlite3 APIs you can access on the iPhone would be a library. Again, that's just me. Other people may interpret the terms differently.

至于库和框架之间的区别,这可能有点主观。对我来说,一个库(在你的问题的上下文中)是用C编写的东西,可能更接近于非OO函数集合。如上所述,框架将是一个完整的类包。因此CocoaDev上的Messaging框架将是一个框架,而您可以在iPhone*问的sqlite3 API将是一个库。再一次,那只是我。其他人可能会不同地解释这些术语。