Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cdub16

macrumors member
Original poster
ok so i have an object. lets say its called TestObject.
in TestObject's constructor, one of its attributes is another TestObject.

so lets say i do this after i have already made the TestObject class, constructer, getter setter methods, ect.


Code:
TestObject *testObject1 = [[TestObject alloc]initWithTestObject:testObject2];
TestObject *testObject2 = [[TestObject alloc]initWithTestObject:testObject1];

it complies correctly but when i try to access testObject1.testObject, it comes back as null, is this because of how i am accessing the object?
 
Can you show us the constructor? It sounds like you are recursing?

ok so i have an object. lets say its called TestObject.
in TestObject's constructor, one of its attributes is another TestObject.

so lets say i do this after i have already made the TestObject class, constructer, getter setter methods, ect.


Code:
TestObject *testObject1 = [[TestObject alloc]initWithTestObject:testObject2];
TestObject *testObject2 = [[TestObject alloc]initWithTestObject:testObject1];

it complies correctly but when i try to access testObject1.testObject, it comes back as null, is this because of how i am accessing the object?
 
ok so i have an object. lets say its called TestObject.
in TestObject's constructor, one of its attributes is another TestObject.

so lets say i do this after i have already made the TestObject class, constructer, getter setter methods, ect.


Code:
TestObject *testObject1 = [[TestObject alloc]initWithTestObject:testObject2];
TestObject *testObject2 = [[TestObject alloc]initWithTestObject:testObject1];

it complies correctly but when i try to access testObject1.testObject, it comes back as null, is this because of how i am accessing the object?

Well obviously testObject1.testObject is null. When you pass it into the constructor of testObject1, it doesn't exist!

You're not showing all of the code involved though because I can't see how the above code could possibly exist unless you've already declared testObject2 somewhere else.
 
o crap wait i did my constructer in my class wrong.

^^ ya i see what your saying i quicky wrote that but i had it right in my program. i screwed up the constructed my bad
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.