iOS开发笔记 2、Cocoa简明

简介: 历史 NeXSTEP Many years ago Cocoa was known as NeXTSTEP . NeXT Computer developed and released version 1.
历史

NeXSTEP

Many years ago Cocoa was known as NeXTSTEP . NeXT Computer developed and released version 1.0 ofNeXTSTEP in September of 1989, and versions 2.0 and 3.0 followed not far behind (in 1990 and 1992,respectively). In this early phase, NEXTSTEP was more than an application environment; the term referred tothe entire operating system, including the windowing and imaging system (which was based on DisplayPostScript), the Mach kernel, device drivers, and so on.Back then, there was no Foundation framework. Indeed, there were no frameworks; instead, the softwarelibraries (dynamically shared) were known as kits, the most prominent of them being the Application Kit.Much of the role that Foundation nowoccupieswas taken by an assortment of functions, structures, constants,and other types. The Application Kit itself had a much smaller set of classes than it does today. In addition to the Application Kit, the early NeXTSTEP included the Sound Kit and the Music Kit, librariescontaining a rich set of Objective-C classes that provided high-level access to the Display Postscript layer foraudio and music synthesis.

 

OpenStep

In early 1993 NeXTSTEP 3.1 was ported to (and shipped on) Intel, Sparc, and Hewlett-Packard computers.NeXTSTEP 3.3 alsomarked amajor new direction, for it included a preliminary version of Foundation. Aroundthis time (1993), the OpenStep initiative also took form. OpenStep was a collaboration between Sun andNeXT to port the higher levels of NeXTSTEP (particularly the Application Kit and Display PostScript) to Solaris.The “Open” in the name referred to the open API specification that the companies would publish jointly. Theofficial OpenStep API, published in September of 1994, were the first to split the API between Foundationand Application Kit and the first to use the “NS” prefix.

By June 1996 NeXT had ported and shipped versions of OpenStep 4.0 that could run Intel, Sparc, andHewlett-Packard computers as well as an OpenStep runtime that could run on Windows systems. Sun alsofinished their port of OpenStep to Solaris and shipped it as part of their Network Object ComputingEnvironment. OpenStep, however, never became a significant part of Sun’s overall strategy.

Cocoa

When Apple acquired NeXT Software (as it was then called) in 1997 ,OpenStep became the Yellow Box andwas included with Mac OS X Server (also known as Rhapsody) and Windows. Then, with the evolution of theMac OS X strategy, it was finally renamed to “Cocoa.”

Cocoa Framework

框架的组成,包括基础和应用

■ Mac OS X: Foundation and Application Kit

■iOS: Foundation and UIKit

Foundation

The Foundation framework defines a base layer of classes that can be used for any type of Cocoa program.The criterion separating the classes in Foundation from those in the Application Kit is the user interface.

Application Kit (Mac OS X)

The Application Kit (which is sometimes referred to as the AppKit) is a framework containing all the objectsyou need to implement your graphical, event-driven user interface on Mac OS X: windows, dialogs, buttons,menus, scrollers, text fields—the list goes on.

UIKit (iOS)

The UIKit framework on iOS is the sister framework of the Application Kit onMac OS X. Its purpose is essentiallythe same: to provide all the classes that an application needs to construct and manage its user interface.However, there are significant differences in how the frameworks realize this purpose.

Core Data

Core Data is a Cocoa framework that provides an infrastructure formanaging object graphs, including supportfor persistent storage to a variety of file formats. Object-graph management includes features such as undoand redo, validation, and ensuring the integrity of object relationships. Object persistence means that CoreData saves model objects to a persistent store and fetches them when required. The persistent store of aCore Data application—that is, the ultimate form in which object data is archived—can range from XML filesto SQL databases. Core Data is ideally suited for applications that act as front ends for relational databases,but any Cocoa application can take advantage of its capabilities.

Other Frameworks With Cocoa API

除了以上的基础框架以外,还有各种基于Cocoa的其他框架,如:

Sync Services—(Mac OS X only)

Address Book

Preference Panes—(Mac OS X only)

Screen Saver—(Mac OS X only)

iAd—(iOS only)

Map Kit—(iOS only)

知道了这些基本概念后,可以熟悉一下“Cocoa Fundamentals Guide”文档

然后参考一些相关的文档和例子就可以熟悉整个的框架情况

Cocoa Fundamentals Guide

■ Cocoa Fundamentals Guide

introduces the basic concepts, terminology, architectures, and design patternsof the Cocoa frameworks and development environment.

http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaFundamentals.pdf

这个官方文档包含了很多信息

特别4,5章描述了Cocoa中使用到的设计模式和对象之间的通讯形式,非常重要,否则使用这些类时,如果对设计模式等不熟悉的话,估计会一头雾水

相关文章
|
5天前
|
Unix 调度 Swift
苹果iOS新手开发之Swift 中获取时间戳有哪些方式?
在Swift中获取时间戳有四种常见方式:1) 使用`Date`对象获取秒级或毫秒级时间戳;2) 通过`CFAbsoluteTimeGetCurrent`获取Core Foundation的秒数,需转换为Unix时间戳;3) 使用`DispatchTime.now()`获取纳秒级精度的调度时间点;4) `ProcessInfo`提供设备启动后的秒数,不表示绝对时间。不同方法适用于不同的精度和场景需求。
17 3
|
4天前
|
Swift iOS开发 Kotlin
苹果iOS新手开发之Swift中实现类似Kotlin的作用域函数
Swift可通过扩展实现类似Kotlin作用域函数效果。如自定义`let`, `run`, `with`, `apply`, `also`,增强代码可读性和简洁性。虽无直接内置支持,但利用Swift特性可达成相似功能。
23 7
|
1天前
|
移动开发 前端开发 iOS开发
探索iOS开发的未来:SwiftUI与Combine的融合
随着苹果公司不断推进其操作系统的更新,iOS开发领域也迎来了诸多变革。在这篇文章中,我们将深入探讨SwiftUI和Combine这两个强大的框架,它们如何共同塑造着iOS应用开发的未来趋势。通过具体实例和数据支持,本文旨在揭示这些技术如何简化开发者的工作流,提升用户界面构建的效率,以及加强应用的响应性和性能表现。我们还将提出一个开放性问题,邀请读者思考并探索这些技术在未来可能带来的进一步影响。 【7月更文挑战第26天】
9 2
|
3天前
|
API 数据处理 开发工具
探索iOS开发的未来:SwiftUI和Combine的融合
【7月更文挑战第23天】随着Apple不断推动其软件开发工具的创新,SwiftUI和Combine框架的出现标志着iOS开发进入了一个新的时代。本文将深入探讨这两个框架如何简化界面设计和事件处理,以及它们如何共同为开发者提供一个更加高效、声明式的编程模型。我们将通过实际示例来展示如何利用SwiftUI构建用户界面,并使用Combine处理异步事件和状态管理。文章还将预测这些技术如何塑造iOS应用开发的未来趋势。
|
2天前
|
调度 Swift Android开发
苹果iOS新手开发之Swift中的并发任务和消息机制
Swift的消息机制类似Android的Handler,实现任务调度有三种方式: 1. **Grand Central Dispatch (GCD)**:使用`DispatchQueue`在主线程或后台线程执行任务。 2. **OperationQueue**:提供高级接口管理`Operation`对象。 3. **RunLoop**:处理事件如输入源、计时器,类似Android的`Looper`和`Handler`。 **示例**: - GCD:在不同线程执行代码块。 - OperationQueue:创建操作并执行。 - RunLoop:用Timer添加到RunLoop中。
12 2
|
7天前
|
Swift iOS开发 开发者
探索iOS开发中的SwiftUI框架
【7月更文挑战第19天】在移动应用开发的浪潮中,苹果公司的SwiftUI框架如同一股清新的海风,为iOS开发者带来了前所未有的编程体验。本文将深入探讨SwiftUI的核心特性,揭示其如何简化界面设计流程,提升开发效率,并展望SwiftUI在未来iOS开发领域的发展潜力。通过实例分析,我们将一同见证SwiftUI如何塑造更加直观、高效的编程模式。
|
3天前
|
前端开发 Android开发 iOS开发
探索安卓与iOS开发的差异性与互补性
在移动应用开发的广阔舞台上,安卓和iOS这两大操作系统各据一方,引领着市场潮流。它们在技术架构、开发环境及用户群体等方面展现出独特的差异性,同时也存在着潜在的互补性。本文将深入剖析这两种平台的开发细节,从不同角度揭示其各自优势及相互之间的协同潜力,为开发者提供全面而深刻的视角。
10 2
|
4天前
|
前端开发 Swift iOS开发
探索iOS开发的未来:SwiftUI和Combine的融合
在iOS开发领域,SwiftUI和Combine框架的出现标志着一个新时代的到来。本文深入探讨这两个框架如何共同推动iOS应用开发的现代化,通过具体案例分析它们的优势、挑战以及未来趋势。
|
4天前
|
数据处理 Swift iOS开发
探索iOS开发的未来之路:SwiftUI和Combine框架的融合
在本文中,我们将深入探讨iOS开发的新趋势——SwiftUI和Combine框架的结合使用。我们将从这两个框架的基本概念入手,逐步解析它们如何协同工作,以实现更加高效、响应式的用户界面构建。通过实例演示,我们将揭示这种组合如何简化代码结构,提高开发效率,并增强应用性能。最后,我们将展望这种技术栈在未来iOS开发中的潜在影响和应用前景。
|
7天前
|
开发工具 Android开发 Swift
探索Android与iOS开发的差异与挑战
【7月更文挑战第20天】在移动应用开发的广阔天地中,Android和iOS两大平台如同双子星座,各自闪耀着独特的光芒。本文将深入探讨这两个平台在开发过程中的主要差异,以及开发者面临的技术挑战。我们将从开发环境、编程语言、用户界面设计、性能优化、安全性考量等多个维度展开讨论,旨在为那些即将踏入或已在这片星空下航行的开发者提供一盏明灯。