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