having issues getting a value from a NSString in my view controller to my delegate. The issue is the userId string. it comes back with an error in the delegate
error: accessing unknown ‘userId’ class method
view controller snippet ( profileViewController.m )
-(void)parserDidEndDocument:(NSXMLParser *)parser
{
NSDictionary *rowData = [self.userArray objectAtIndex:0];
self.userId = [[NSMutableString alloc] initWithFormat:@"%@", [rowData objectForKey:@"id"]];
NSLog(@"DONE PARSING DOCUMENT");
NSLog(self.userId);
}
- (void)viewDidLoad
{
self.title = @"Profile";
interestingTags = [[NSSet alloc] initWithObjects: INTERESTING_TAG_NAMES];
self.userArray = [[NSMutableArray alloc] init];
[super viewDidLoad];
}
delegate
#import "profileViewController.h"
@implementation experimentAppDelegate
@synthesize window;
@synthesize rootController;
-(void)goingOffline
{
NSMutableData *data = [NSMutableData data];
NSString *userID = profileViewController.userId;
NSString *userString = [[NSString alloc] initWithFormat:@"id=%@", userID];
//NSLog(nameString);
//NSLog(numberString);
[data appendData:[userString dataUsingEncoding:NSUTF8StringEncoding]];
NSURL *url = [NSURL URLWithString:@"http://www.website.net/test.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:data];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSLog(@"responseData: %@", responseData); }
profileViewControlleris your class. To accessuserIddirectly, it should be defined as,and not,
Edit
Since
profileViewControlleris one of the view controllers in the tab bar controller instancerootController, you can try getting theprofileViewControllerinstance like this,