views:

68

answers:

2

Hi all i am new to objective c programming I want to call a function within anothor method please give me idea.

-(void) grabRSSFeed:(NSString *)blogAddress {

    // Initialize the blogEntries MutableArray that we declared in the header
    myBlogEntries = [[NSMutableArray alloc] init];  

    // Convert the supplied URL string into a usable URL object
    NSURL *url = [NSURL URLWithString: blogAddress];

    // Create a new rssParser object based on the TouchXML "CXMLDocument" class, this is the
    // object that actually grabs and processes the RSS data
    CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease];

    // Create a new Array object to be used with the looping of the results from the rssParser
    NSArray *resultNodes = NULL;

    // Set the resultNodes Array to contain an object for every instance of an  node in our RSS feed
    resultNodes = [rssParser nodesForXPath:@"//item" error:nil];

    // Loop through the resultNodes to access each items actual data
    for (CXMLElement *resultElement in resultNodes) {

        // Create a temporary MutableDictionary to store the items fields in, which will eventually end up in blogEntries
        NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];

        // Create a counter variable as type "int"
        int counter;

        // Loop through the children of the current  node
        for(counter = 0; counter < [resultElement childCount]; counter++) {

            // Add each field to the blogItem Dictionary with the node name as key and node value as the value
            [blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];

        }       
        // Add the blogItem to the global blogEntries Array so that the view can access it.
        [myBlogEntries addObject:[blogItem copy]];

    }  
}

want to call above function in Babes Method

    -(IBAction)babes
{   
    myview.hidden = FALSE;

    [myview startAnimating];



    feedurl = @"http://www.luxury.net/feed/rss/babes.xml";
    //want to call it here.....

    [self performSelector:@selector(moveAlert:) withObject:nil afterDelay: 0.7f];

}

but its not working please help me out thanks in advance.

+1  A: 

You use self just as you are doing already, but you have to supply the argument correctly.

[self grabRSSFeed:@"http://someurl.com"];

The blogAddress is an NSString that you must supply somehow. For example, if you have a text view called textViewRSSFeed in your app, you would supply the value for that field.

[self grabRSSFeed:textViewRSSFeed.text];
Kalle
please view my question i have edit it
Nauman.Khattak
Greensource is spot on -- you need to go RTFM. Your problem is solved with [self grabRSSFeed:feedurl]; though, for what it's worth.
Kalle
+2  A: 

You need to read the beginner documentation, start here: Learning Obj-C

For your problem specifically, try this:

NSString* aBlogAdress = @"http://anAdress.com";
[self grabRSSFeed:aBlogAddress];
Greensource
please view my question i have edit it
Nauman.Khattak
@Greensource: To be picky, your second line is a typo -- should be "aBlogAddress", not "blogAddress". Otherwise, 100% agreed.
Kalle
@Kalle thks, I edited that
Greensource