iPhone开发人员学习的关键概念是什么? [英] What are the key concepts for an iPhone Developer to learn?

查看:126
本文介绍了iPhone开发人员学习的关键概念是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Objective-C的新手,我已经经历了许多主题,我应该更加强调开发iPhone应用程序的关键概念是什么?

I'm new to Objective-C and I have gone through many topics, What are the key concepts on which I should put more emphasis for developing iPhone Apps?

推荐答案

有许多概念构成iOS开发的基础。

There are a number of concepts which make up the basics of iOS development. There coding patterns, techniques and some general tidbits that you should know about.

编码模式:


  • 键值观察(KVO):允许一个对象通过将Observer注册到target来响应另一个对象属性的更改对象。有关KVO的详情,请参阅Apple的键值观察编程指南

  • Key Value Observing (KVO): Allowing one object to respond to changes of another object's properties by registering the "Observer" with the "target" object. For more on KVO, see Apple's Key-Value Observing Programming Guide.

模型视图控制器模式:在模型视图控制器模式(MVC)中,对象通常适合三种角色之一。您有模型,即最基本的级别,您的数据。 (或者,更准确地说,数据是如何结构化的)。你有查看,这是用户在屏幕上看到的。最后,您有控制器,它在模型视图之间进行协调。 是您的业务逻辑通常所在的地方。

Model View Controller Pattern: In the Model View Controller Pattern (MVC) objects generally fit into one of three roles. You have the Model, which is, at the most basic level, your data. (Or, more accurately, how the data is structured.) You have the View, which is what the user sees on the screen. Lastly, you have the Controller, which coordinates between the the model and the view. The controller is where your business logic usually goes. Apple has documentation on MVC as well.

Singleton模式: Singleton类(这是一个矛盾,单例类)类,它们在一个应用程序中一次只能有一个实例。单身是有益于工厂类,或对象,你不会想要两个。例如, UIDevice 类是一个单例类。 (你的iPhone不是一个iPad和iPhone的同时,现在是吗?)在iOS SDK中,单例类常常有一个特殊的初始化。而不是通常的 [[Class alloc] init] ,单例通常使用 [SingletonClass sharedInstance] 。 (shared实例,因为实例在你的应用程序中是共享的)。注意Singleton类在内存管理方面有些不同。

The Singleton Pattern: Singleton classes (that's an oxymoron, "singleton classes") are classes which can only have one instance of them in an application at a time. Singletons are good for "factory classes", or objects that you won't want two of. The UIDevice class, for example, is a singleton class. (Your iPhone isn't an iPad and an iPhone at the same time, now is it?) In the iOS SDK, singleton classes often have a special initializer. Instead of the usual [[Class alloc] init], singletons often use [SingletonClass sharedInstance]. ("shared"Instance, since the instance is "shared" across your application.) Note that Singleton classes work a little differently in regards to memory management.

编码技术


  • strong>:iOS SDK中的许多对象都有代理对象,它们响应它们委派的对象的某些事件。例如,你可以有一个 UIPickerView (一个滚动轮上有一堆的选择)。当用户选择一个日期时,委托(与UIPickerView不同的对象)将实现 - pickerView:didSelectRow:inComponent:,这将允许该对象做某事

  • Delegation: Many objects in the iOS SDK have delegate objects, that respond to certain "events" of the object that they are "delegating" for. For example, you could have a UIPickerView (a scrolling wheel with a bunch of choices on it). When the user chooses a date, the delegate, ( a different object than the UIPickerView) will implement – pickerView:didSelectRow:inComponent:, which will allow that object to do something in response to the action.

内存管理:与许多语言不同,无论是Java,Javascript还是通常管理内存为你。在iOS上,Objective-C不会 这样做。你需要跟踪你的所有对象,并释放他们,当你完成他们。经验法则是每个 alloc retain new copy ,您必须具有相应的版本关于自动发布的注意事项:人们通常对理解 autorelease autoreleased对象被保证在方法调用结束之前,没有更多,不少。当然,如果你在其他地方保留对象,它仍然会有一个引用。)

Memory Management: Unlike many languages, be it Java, Javascript, or anything in between usually manage memory for you. On iOS, Objective-C does not do this. You need to keep track of all of your objects and release them when you are finished with them. The rule of thumb is that for every alloc, retain, new, and copy, you must have a corresponding release, or autorelease. (A note about autorelease: People often have trouble with understanding autorelease. Generally speaking, local "autoreleased" objects are guaranteed to be around until the end of method call. No more, no less. Of course, if you retain the object elsewhere, it will still have a reference from that point.)

ARC :使用iOS 5 SDK,Apple引入了自动引用计数。重要的是要了解这是如何工作的基础知识,即使你打算使用手动引用计数。你永远不知道什么时候会遇到需要使用的ARCified代码。

ARC: With the iOS 5 SDK, Apple introduced Automatic Reference Counting. It's important to understand the basics of how this works, even if you plan on working with manual reference counting. You never know when you'll run into ARCified code that you'll need to work with.

数据持久性:许多开始使用的人员在启动之间保存数据时也遇到了挑战。您有三个选项,具体取决于数据的类型。您可以使用 NSUserDefaults ,文档目录(或其中一个您应用程序目录层次结构中的其他文件夹,或核心数据,您也可以

Data Persistence: Many folks who are getting started also have a challenge with saving data in between launches. You have three options, depending on the type of data. You can use NSUserDefaults, the Documents Directory (or one of a few other folders in your App's directory hierarchy, or Core Data. You also use these in conjunction with each other, as they are not mutually exclusive.

基本概念:


  • IBOutlets和IBActions IBAction void IBOutlet 都是 typedef code> IBAction 方法返回 void 并标记为 IBAction Builder可以允许您将它们附加到NIB文件中的对象。 IBOutlet 在代码中是占位符,用于允许您设置属性或与对象交互

  • IBOutlets and IBActions: IBAction and IBOutlet are typedefs for void. IBAction methods return void and are marked as IBAction so that Interface Builder can allow you to attach them to objects in your NIB files. IBOutlets are "placeholders" in code that are used to allow you to set properties, or otherwise interact with objects in your NIB files via Objective-C code.

@符号 @ 符号表示Objective-C常量,因为Objective-C是C上的超集或框架。在C中,字符串常量将我的字符串很酷。。在Objective-C中它将是 @我的字符串在Objective-C中更凉爽。 @ 用于区分C和Objective-C的符号是 @implementation @property @class @end

The @ symbol: The @ symbol represents Objective-C constants, since Objective-C is a superset or Framework on top of C. In C, a string constant would be "My string is cool.". In Objective-C it would be @"My string is cooler in Objective-C." Other examples of the @ symbol being used to distinguish between C and Objective-C are keywords like @implementation, @property, @class and @end.

:Dave DeLong在他的回答中解释这一点,但这是别的东西,以确保你也知道。

Pointers: Dave DeLong explains this in his answer, but this is something else to make sure you know as well.

最后,我给你一个忠告:

Finally, I leave you with a word of advice:

虽然你有StackOverflow,它真的是一个美好的资源,知道如何使用 Apple文档 。享受您的旅程和好运气入门

Although you have StackOverflow, and it really is a wonderful resource, know how to use the Apple Documentation. Enjoy your journey and good luck Getting Started!

祝你好运!

这篇关于iPhone开发人员学习的关键概念是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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