PDA

View Full Version : How To Access Values Of BOOL, CGFloat, Etc. From Another Class?




Darkroom
Sep 6, 2009, 01:16 AM
so in my SomeRandomClass i have a boolean called someRandomBool. i'm attempting to access the current value of said bool thru AnotherClass:


#import <UIKit/UIKit.h>
@class SomeRandomClass;

@interface AnotherClass : UIViewController
{
SomeRandomClass *someRandomClassInstance;
}

@property (nonatomic, retain) IBOutlet SomeRandomClass *someRandomClassInstance;

@end

-=-=-=-

#import "AnotherClass.h"
#import "SomeRandomClass.h"


@implementation AnotherClass

@synthesize someRandomClassInstance;

- (void)loadView
{
if (someRandomClassInstance.someRandomBool == YES)
NSLog(@"Bool Is YES");
else
NSLog(@"Bool Is NO");
}
@end


... doesn't work.



dejo
Sep 6, 2009, 01:22 AM
Where do you set the value of someRandomClassInstance?

Darkroom
Sep 6, 2009, 01:25 AM
Where do you set the value of someRandomClassInstance?

i connect it to a proxy object in IB

eddietr
Sep 6, 2009, 09:21 AM
i connect it to a proxy object in IB

A proxy object or an actual object?

Darkroom
Sep 6, 2009, 09:28 AM
A proxy object or an actual object?

it's a UITableViewCell subclass ("AnotherClass") accessing a UIViewController class ("SomeRandomClass") thru a proxy object.

i fail to see where this is going...

Kingbombs
Sep 6, 2009, 11:58 AM
because usually and what works is if you have
SomeClass *instanceOfClass
in the .h
then in the viewDidLoad you would have
instanceOfClass = [[SomeClass alloc] init];
then you can do
if ([instanceOfClass someBool])
// code if its set to true


And people are asking to try and understand what you have done instead

Also what errors are you getting?
are they build time errors or run time errors?

dejo
Sep 6, 2009, 02:07 PM
Is someRandomClassInstance set to the correct value when this line is executed?:
if (someRandomClassInstance.someRandomBool == YES)

eddietr
Sep 6, 2009, 06:02 PM
i fail to see where this is going...

Just trying to figure out the circumstances here.

So is your proxy being resolved correctly? Is someRandomClassInstance equal to nil by any chance?

Darkroom
Sep 6, 2009, 07:08 PM
i'm officially an idiot... officially... really, it's official.

the problem was that i hadn't set properties on the boolean variables, so the instance of the class couldn't access them...

thank you for all your help.