如何与整个项目共享一个对象? [英] How to share an object with the entire project?

查看:62
本文介绍了如何与整个项目共享一个对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我在一个类中创建UILabel,该如何在任何地方使用它?

For example, if I create an UILabel in an class, how can I use it wherever I want to?

我已经知道如何在两个类之间共享。但是我需要在所有类中调用一个对象的值。可能吗?

I already know how to share between two classes. But I need to call the value of an object in all my classes. Is it possible?

推荐答案

您想要单身吗?基本上,单例只是一个无论如何都只返回相同实例的类。这是一个向您展示如何操作的网站。 http://funwithobjc.tumblr.com/post/3478903440/how -i-do-my-singletons

Is a singleton what you want? Basically a singleton is just a class that only returns the same instance no matter what. Here's a website that shows you how to do them. http://funwithobjc.tumblr.com/post/3478903440/how-i-do-my-singletons

这篇关于如何与整个项目共享一个对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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