在objective-c中使用Singleton类有什么用? [英] What is the use of Singleton class in objective-c?

查看:124
本文介绍了在objective-c中使用Singleton类有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Singleton类是一个类,一次只能创建一个对象。

I know Singleton class is a class whose only one object can be created at a time.

我的问题是:

1. 什么是使用Singleton类在objective-c?

1.What is the use of Singleton class in objective-c?

2. 如何创建和使用创建的Singleton类?

2.How to create and use the created Singleton class?

推荐答案

单例是一种特殊类,其中当前进程只存在一个类的实例。对于iPhone应用程序,整个应用程序共享一个实例。

A singleton is a special kind of class where only one instance of the class exists for the current process. In the case of an iPhone app, the one instance is shared across the entire app.

看看这些教程:

http://pixeleap.com/?p=19

http://www.codeproject.com/Tips/232321/Implement-Objective-C-Singleton-Pattern

http://xcodenoobies.blogspot.in/2012/08/how-to-pass-data-between.html

http://www.johnwordsworth.com/2010/ 04 / iphone-code-snippet-the-singleton-pattern /

http://www.idev101.com/code/Objective-C/singletons.html

这个视频教程:

http://www.youtube.com/watch?v=FTfEN8KQPK8

这篇关于在objective-c中使用Singleton类有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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