Does shared object of delegate reserves memory?
I am writing like below in different classes and methods of my app.
FruityGameAppDelegate *delegate = (FruityGameAppDelegate *)[[UIAp开发者_如何转开发plication sharedApplication] delegate];
I want to know that will it occupy the space(memory) or if yes then what be the suitable way to play with such objects so it my program should not leak the memory, or should not be heavy?
No, it does not occupy additional memory as the UIAppDelegate already exists. You're only assigning a pointer to it (think: you're only putting up a road sign "To delegate: this way" instead of building a new one).
No, it definitely does not occupy any additional memory. You have already created an instance of the appdelegate and as Darkdust mentioned you are just using a different pointer which points to the same and only instance of the app delegate. what you are doing is nothing but referring your existing memory location for the object using a different pointer.
No it wont occupy additional memory. When you copy it onto a new variable it will occupy additional memory. Consider a scenario where you have multiple pointers pointing to the same piece of memory. In such scenario when the memory is freed up, all the other pointers become dangling. It may lead to serious issues like application crash. However if you read about the different properties of variables on how you can access them in apples documentation you will be very clear on how you can use the allocated variables across your app.
精彩评论