0
我应该使用AppDelegate共享数据吗?应该使用AppDelegate共享数据吗?
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
我的朋友说为此使用AppDelegate是不好的,因为它使用更多的内存。
我应该使用AppDelegate共享数据吗?应该使用AppDelegate共享数据吗?
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
我的朋友说为此使用AppDelegate是不好的,因为它使用更多的内存。
它不使用更多的内存:无论在哪里,都需要N个字节来存储数据。但从程序员的角度来看这是一个不好的做法,因为它打破了MVC分离和自我控制的原则。
您应该提供有关需要共享和存储的数据类型的更多信息。
我使用@property(strong,nonatomic)NSMutableString * data;和 data = [[NSMutableString alloc] init];和AppDelegate * appdelegate =(AppDelegate *)[[UIApplication sharedApplication] delegate]; [appdelegate.data setString:STD];类似的东西 –
它的用途是什么?必须有一些更好的地方放置它,这取决于你如何在控制器之间传递这个对象。 – Cyrille