Here is my code snippit:
- (void) getData: (NSNotification *)aNotification{
NSData *data = [[aNotification userInfo] objectForKey:NSFileHandleNotificationDataItem];
if ([data length])
{
return [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
} else {
[self stopProcess];
}
[[aNotification object] readInBackgroundAndNotify];
}
Ok, so how do I set an NSString to the value of getData anywhere else in my application?
Thanks,
Elijah
Well, first of all, you can’t return an
NSStringobject from avoidfunction.Secondly, it looks like this method is triggered via the notification system. Setting an
NSStringto a value ofgetDataanywhere in your application would require having (a) an object, and (b) a way to set anNSStringon that object.Basically, notifications happen asynchronously. Your
getDatamethod can only extract the string value and pass it via a message to other objects it knows about.