Re: Newb Question re Messaging and Return Values
Re: Newb Question re Messaging and Return Values
- Subject: Re: Newb Question re Messaging and Return Values
- From: Brad Gibbs <email@hidden>
- Date: Thu, 24 Jul 2008 16:04:59 -0700
Looking at my problem further, I'm thinking I should make webServer a
delegate of each of the devices. That would allow me to encapsulate
the HTTP Posts and Gets for all of the devices in a single class. A
device's methods could invoke the webServer delegate when they need to
send information to the server or get information back. The webServer
delegate would return the response to the device method that called
the webServer method and that method could parse the response and
update the UI directly or through an NSNotification.
Does this sound right?
Thanks again.
On Jul 24, 2008, at 11:00 AM, Brad Gibbs wrote:
I'm having a hard time understanding return values and maybe
messaging in general. I've looked through Programming in Objective-
C, Hillegass Third Edition and through Apple's documentation, but
don't seem to know enough to find the answer or a proper example I
can implement.
I have a view controller that handles button presses, tracks
variables and updates button states and text fields for a number of
devices represented on the UI. A button press
- (IBAction)statusQuery:(id)sender;
sends a message from the view controller to an object named device.
The device object has a method
- (NSString *)statusQuery {
[webServer getVariableValueByName:@"status"];
}
webServer is an instance of a class that handles HTTP Posts to a web
server on my local network via NSURLConnection. This is working
well and webServer is getting the expected responses and logging
them to the console. But, I can't figure out how to send the
response string from the connectionDidFinishLoading method of the
webServer object back to the device's statusQuery method, which
needs to parse the response and send the parsed response back to the
view controller to update the UI.
I'm hoping for a generic message that can send any response back to
any object that invokes the NSURLConnection method.
connectionDidFinishLoading is set to return (NSString *). Is it
possible to have the delegate method connectionDidFinishLoading send
its response back to the object that invoked the NSURLConnection
request? If so, what is the proper syntax?
Thanks.
Brad
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden