Solved

How to call a function (method) in Objective C

Posted on 2009-07-13
2
8,758 Views
Last Modified: 2013-11-25
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

0
Comment
Question by:enjay99
2 Comments
 
LVL 5

Accepted Solution

by:
AGoodKeenMan earned 250 total points
Comment Utility
You almost had it,

[self parse:data];
0
 

Author Closing Comment

by:enjay99
Comment Utility
Thank you for your excellent response
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Let Bitmoji into your life. Now is the time to learn a new language of smartphone messaging with this brief introduction.
Set up iPhone and iPad email signatures to always send in high-quality HTML with this step-by step guide.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now