Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 14, 2011, 06:24 PM   #1
chen8002004
macrumors newbie
 
Join Date: May 2011
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.
chen8002004 is offline   0 Reply With Quote
Old Jun 15, 2011, 02:48 AM   #2
jnoxx
macrumors 65816
 
jnoxx's Avatar
 
Join Date: Dec 2010
Location: Aartselaar // Antwerp // Belgium
U could hold a singleton, and put the date in there
(look for SynthesizeSingleton.h)
jnoxx is offline   0 Reply With Quote
Old Jun 15, 2011, 04:49 AM   #3
xStep
macrumors 68000
 
Join Date: Jan 2003
Location: Indianapolis, for an unknown time
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.
xStep is offline   0 Reply With Quote
Old Jun 16, 2011, 08:02 PM   #4
chen8002004
Thread Starter
macrumors newbie
 
Join Date: May 2011
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
chen8002004 is offline   0 Reply With Quote
Old Jun 16, 2011, 09:24 PM   #5
xStep
macrumors 68000
 
Join Date: Jan 2003
Location: Indianapolis, for an unknown time
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;
or

Code:
@property (assign) C* iC;

Last edited by xStep; Jun 16, 2011 at 11:43 PM. Reason: Fixed spelling.
xStep is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC