Link to home
Start Free TrialLog in
Avatar of enjay99
enjay99

asked on

How to call a function (method) in Objective C

Hi Experts,

I am trying to develop an iPhone application that gets some data from a socket and parses it for display. I basically have it working, but would like to pass some of the logic to a function to have it parse and display the data.

In the code snippets attached I would like to create a function called "parse" and have it work on the string "data".

I have a tried all of the syntax I can think of like:
"void parse(data);", "[parse:data]", "[data:parse]", etc. to call the function

The code is from mainview.m

Thank you in advance.
// Data Received //
NSString *data;
data = [[NSString alloc] initWithFormat: @"%@\n%@", resultText.text, output];
    if (data = @"rt=ok")
    {
         servername.text = data;  //THIS WORKS
    }
    else{
          void parse(data);           // CALL THE FUNCTION FROM HERE
    }
 
 
- (void)parse:data {
    NSLog("PARSING DATA");
    txtsend.text = data;
    return;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of AGoodKeenMan
AGoodKeenMan
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of enjay99
enjay99

ASKER

Thank you for your excellent response