Apple Developer文档笔记(一)AppKit App Structure

导语

这篇文章是方便自己学习理解苹果开发者的文档的笔记,希望能给有需要的同学一些帮助,因为自己翻译理解的内容,
必然存在一些不足,还望指出。

Apple Developer

(https://developer.apple.com/)  *苹果开发者网站

1.Core

(1)Application

	class NSApplication
	
		Declaration(声明)
		class NSApplication : NSResponder
		
		Overview(综述)
		Every app uses a single instance of NSApplication to control the main event
		 loop, keep track of the app’s windows and menus, distribute events to the 
		appropriate objects (that is, itself or one of its windows), set up 
		autorelease pools, and receive notification of app-level events.
		
		*注释
		class NSApplication 在被实例化之后控制整个应用主体的事件循环,并且跟踪应用
		轨迹,并将事件分配给合适的对象,建立 autorelease pools ,接受来自应用层的事
		件通知。
		
	class NSRunningApplication
		
		Declaration(声明)
		class NSRunningApplication : NSObject
		
		Overview(综述)
		Some properties of an app are fixed, such as the bundle identifier. Other 
		properties may vary over time, such as whether the app is hidden. 
		Properties that vary can be observed with key-value observing, in which 
		case the description comment for the method notes this capability.
		
		An NSRunningApplication instance remains valid after the app exits. However, 
		most properties lose their significance, and some properties may not be 
		available on a terminated application.
		
		*注释
		在一个应用内的一些已经被固定得工程,例如打包的标识府。另外一个工程可能已经
		超时,例如被隐藏的应用。有些工程的性能和方法的描述注释,在这种情况下应该留
		意敏感的关键值。
		
		一个 NSRunningApplication 实例化之后,当app退出之后仍然是有效的。不过。大部
		分工程失去他们本身的意义,并且在被终止的应用中的有一些工程可能会失效。
		
	protocol NSApplicationDelegate
	
		Declaration(声明)
		protocol NSApplicationDelegate
		
		*注释
		协议授权
		
	function NSApplicationMain
	
		Declaration(声明)
		func NSApplicationMain(_ argc: Int32, 
		_ argv: UnsafeMutablePointer?>) -> Int32
		
		*注释
		函数构造应用主体,参数1 int32类型,参数2,不安全的可变的指针 ->返回一个int32
		的值

(2)Environment

	class NSWorkspace
	
		Declaration(声明)
		class NSWorkspace : NSObject
		
		Overview(综述)
		There is one shared NSWorkspace object per app. You use the class method 
		shared to access it. 
		
		You can use the workspace object to:

			(1)Open, manipulate, and get information about files and devices

			(2)Track changes to the file system, devices, and the user database

			(3)Get and set Finder information for files

			(4)Launch apps
			
		*注释
		这是每一个 app 都拥有的共享的 NSWorkspace 对象。你使用这类方法去共享存取它。
		你可以使用这个工作区对象完成以下操作:
			(1)打开,操作,并且得到这个文件或设备的相关信息
			(2)追踪、改变文件格式,设备和用户数据库
			(3)得到文件的信息和设置文件的信息探测器
			(4)注册apps

(3)Pasteboard

	class NSPasteboard
	
		Declaration(声明)
		class NSPasteboard : NSObject
		
		Overview(综述)
		The pasteboard server is shared by all running apps. It contains data that 
		the user has cut or copied, as well as other data that one application 
		wants to transfer to another. NSPasteboard objects are an application’s 
		sole interface to the server and to all pasteboard operations.

		An NSPasteboard object is also used to transfer data between apps and 
		service providers listed in each application’s Services menu. The drag 
		pasteboard is used to transfer data that is being dragged by the user.
	
		*注释
		这个 pasteboard 服务是对所有运行的apps共享的。它不但包括用户剪切或者复制的
		数据,同时也包括来自同一个应用并将其转换为另一种的其他数据。NSPasteboard 对
		象是一个应用中的唯一的指针对于这个服务器和整个 pasteboard 操作。
		
		在已注册的每一个应用的服务器列表中 NSPasteboard 对象也是转换apps和服务器之间的数据的
		提供者。drag pasteboard 通过用户开始拖动的时候转换数据。

(4)Data Management

	Article	Protecting the User’s Privacy
			
		Overview(综述)
		Designing for user privacy is important. Most Apple devices contain personal
		data that the user doesn’t want to expose to apps or to external entities. 
		If your app accesses or uses data inappropriately, the user might stop 
		using your app and even delete it from their device.

		Access user or device data only with the user’s informed consent obtained 
		in accordance with applicable law. In addition, take appropriate steps to 
		protect user and device data, and be transparent about how you use it.
		
		*注释
		设计用户隐私是很重要的。绝大多数的苹果设备包括用户不想展示或者实际的私人数
		据。如果你的app 不恰当的获取调用数据,这个用户可能会停止使用你的设备甚至从
		他的设备上删除你的应用。
		
		获取用户或则设备的数据只能在用户正式一致同意在可适用的法律下获取。另外,获
		取的适当的步骤去保护用户和设备数据,并且将你使用这些数据的方法变得透明公开。

(5)User Preferences

	Class NSUserDefaultsController
	
		Declaration(声明)
		class NSUserDefaultsController : NSController
	
		Overview(综述)
		NSUserDefaultsController is a Cocoa bindings–compatible controller class. 
		Properties of the shared instance of this class can be bound to user 
		interface elements to access and modify values stored in UserDefaults.
	
		*注释
		NSUserDefaultsController 是一个 Cocoa bindings–compatible 控制器类。内容上
		这个共享实例化之后对于这个类可能束缚在用户的指针元素上去获取并且更改储存在
		UserDefaults 上的值

(6)App Services

	Class NSSharingService
		
		Declaration(声明)
		class NSSharingService : NSObject
		
		Overview(综述)
		The NSSharingService class is used to provide a consistent user experience 
		when sharing items—NSURL objects, NSString objects, NSImage objects, video
		(through file URLs), or any object that implements the NSPasteboardWriting 
		protocol—in macOS.

		For any item or group of items, the NSSharingService displays a sharing 
		sheet that lets the user visualize what will be shared to the service. A 
		sharing service can: create a post on a social network like Twitter or 
		Facebook, send a message by email or iMessage, upload videos to viewing 
		services, or send a file by AirDrop.
	
		*注释
		这个 NSSharingService 类 当共享当分享 NSURL 对象,NSString 对象,NSImage 对
		象,视频(来源url文件),或者任何来自 macOS 中的 NSPasteboardWriting 协议里
		的对象,被作为提供一个一致的用户体验的工具
		
		对于任何项目或集群下的项目,这个 NSSharingService 展示的共享内容来自让用户
		将共享的内容可视化通过这个服务。一个共享服务能做:创建一条像Twitter or 
		Facebook的请求,发送邮件内容或者iMessage,上传视频给 viewing 服务,或者通过
		AirDrop 发送文件。
		
	Class NSSharingServicePicker
		
		Declaration(声明)
		class NSSharingServicePicker : NSObject
		
		Overview(综述)
		The NSSharingServicePicker class presents a list of sharing services, so 
		that the user can choose a service to share an item. When a service is 
		chosen, the picker automatically executes it, which presents the sharing 
		window.

		The NSSharingServicePickerDelegate allows customizing the picker’s 
		available services, where it appears, and allows assigning the delegate 
		object for the NSSharingService delegate.
	
		*注释
		这个 NSSharingServicePicker 类展示一个共享服务的列表,以至于让用户能选择服
		务去分享项目。当这个服务被选中时,这个选择器自动地执行展示在共享窗口上的这
		个服务。
		
		这个 NSSharingServicePickerDelegate 允许定制化的选择器的有效服务,并且允许
		设定这个代表对象作为 NSSharingService 代表分配任务。
		
	Protocol NSSharingServicePickerDelegate
	
		Declaration(声明)
		protocol NSSharingServicePickerDelegate
	
		*注释
		共享服务选择协议(参考 NSSharingServicePicker 获取更多信息)
	
	Protocol NSServicesMenuRequestor
	
		Declaration(声明)
		protocol NSServicesMenuRequestor
		
		Overview(综述)
		This informal protocol consists of two methods, writeSelection(to:types:) 
		and readSelection(from:). The first method provides data to a remote 
		service, and the second receives any data the remote service might send 
		back. Both respond to messages that are generated when the user chooses a 
		command from the Services menu.
		
		*注释
		这个非正式协议包含两个方法,写入项(to:type:)和读取项(from:)。第一张方
		法提供数据给远程服务器,并且依次接收远程服务器返回的所有数据。同时会创建一条
		回调消息当用户从服务器列表中选择了一个命令后。

(6)App Help

	Class NSHelpManager
		
		Declaration(声明)
		class NSHelpManager : NSObject
	
		Overview(综述)
		The NSHelpManager class provides an approach to displaying online help. An 
		app contains one NSHelpManager object.
		
		*注释
		NSHelpManager 类提供一个展示线上帮助的途径。一个app里包含了一个NSHelpManager
		对象。
		
	Protocol NSUserInterfaceItemSearching
		
		Declaration(声明)
		protocol NSUserInterfaceItemSearching
		
		Overview(综述)
		In general, users find the Help search functionality very useful. However, 
		many large apps don't use Apple Help API because of cross platform 
		requirements, which means that some important Help topics are not presented 
		as part of the Help menu. This API allows developers to incorporate their 
		own Help topics and take full advantage of the Help feature.

		In your app, you implement the NSUserInterfaceItemSearching protocol and 
		then register your object with registerUserInterfaceItemSearchHandler(_:).
		
		*注释
		一般而言,用户寻求帮助性的功能函数十分常见。不过,大多数的apps没有使用Apple
		Help API 是因为通过平台要求,就意味着一些重要的帮助内别是不作为帮助菜单的一
		部分显示。这个Api允许开发者将他们自己的帮助类别包含并充分利用在帮助内容里。
		
		在你的app中,你执行 NSUserInterfaceItemSearching 协议并且注册在你的对象上
		通过 registerUserInterfaceItemSearchHandler(_:).

你可能感兴趣的:(Apple)