|
|
#1 |
|
How to have a reference to the data
I would like to have a seperate class holding the data. Two objects can read and update the data. Is it possible to have one object own the data and the other object hold a pointer to the data? The other object will not retain the data class. Will this solution cause any possible memory leak?
Last edited by chen8002004; Jun 16, 2011 at 07:51 PM. |
|
|
|
0
|
|
|
#2 |
|
U could hold a singleton, and put the date in there
![]() (look for SynthesizeSingleton.h) |
|
|
|
0
|
|
|
#3 |
|
A singleton might be overkill if you really just have the three objects.
You could have object A create and own object C, and then set an ivar in object B to equal the ivar in object A that points to object C. Just don't release object C from object B, unless you retain it there too. |
|
|
|
0
|
|
|
#4 |
|
I did what xStep told me to. These is no error when running, but I get some warnings in Build: “No ‘assign’, ‘retain’, or ‘copy' attribute is specified - ‘assign’ is assumed” and “Assign attribute (default) not appropriate for non-gc object property ‘iC’ “. Can anyone help me with this warning?
Code:
@interface B: NSObject{
C* iC;
}
@property C* iC;
@end
|
|
|
|
0
|
|
|
#5 |
|
Typically for your property statement you'd define at least whether it will perform a copy, a retain of the object id or simple accept an assignment of the id value. I'll leave it to you to learn more.
To remove the warnings, at minimum your code would look something like this; Code:
@property (retain) C* iC; Code:
@property (assign) C* iC; Last edited by xStep; Jun 16, 2011 at 11:43 PM. Reason: Fixed spelling. |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| How many have not upgraded to the 2011 MBA or Lion due to reports of worse battery? | Jobsian | MacBook Air | 7 | Nov 7, 2011 01:38 PM |
| How to supercharge Mini? | ranny2 | Mac mini | 18 | Oct 27, 2011 08:53 PM |
| How To Remove Server Part Of Lion? | hhaydenn | iMac | 2 | Aug 18, 2011 05:21 PM |
| how to make an iso into a img (does not work as an .iso) | mud25 | Mac Basics and Help | 2 | Jul 19, 2011 09:30 PM |
| How to Move Your Data to the iPhone 3G | MacBytes | MacBytes.com News Discussion | 6 | Jul 27, 2008 11:44 PM |
All times are GMT -5. The time now is 04:15 PM.







Linear Mode

