-2

I have two methods in my NSObject.

I would like to know how to set the text in one method from another, and then execute that method from the one where I set the text?

This is what I have done so far.. just getting abit lost trying to pass things between views and setting up tableviews.

- (IBAction) getManufacturers
{
    //set manufacture.php
    NSString *manufactureString = [[NSString alloc] initWithString:@"manufacture.php"];
    submissionString = manufactureString;
    self.grabURLInBackground; //<--- this is wrong, how do I call my other method?
}

//...


- (IBAction)grabURLInBackground:(id)sender
{
    NSURL *url = [NSURL URLWithString:@"http://127.0.0.1:8888/CodeTest/%@", settexthere];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [request startAsynchronous];
}

//UPdated: So what I ended up doing is just adding a NSString paramater to grabURLInBackground method which is set from my other method like describeded below

[self grabURLInBackground:submissionString];

all is well.

Now I just need to figure out how to pass the data I have coming in to a new uitableview.. :) thanks for the help guys.

C.Johns
  • 10,185
  • 20
  • 102
  • 156
  • Your manufactureString is leaking and should be released. Or better yet, just do submissionString = @manufacture.php". And since submissionString is probably a retained property, use this self.submissionString = @manufacture.php" instead. – picciano Aug 31 '11 at 21:41

2 Answers2

1

Like this?

[self grabURLInBackground:nil]

But you may want to move the functionality from grabURLInBackground to another method so that you won't have to pass a dummy nil parameter.

SVD
  • 4,743
  • 2
  • 26
  • 38
1
[self grabURLInBackground:nil];

this should work if you declared the function in the prototype

I think you want to set the string? In this case you need a new function

prototype

- (void) grabURLInBackgroundWithSubmission:(NSString*):submission;

implementation

- (void) grabURLInBackgroundWithSubmission:(NSString*):submission{
    NSURL *url = [NSURL URLWithString:@"http://127.0.0.1:8888/instaCodeTest/%@", submission];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [request startAsynchronous];
}

and call it with [self grabURLInBackgroundWithSubmission:submissionString];

Seega
  • 3,001
  • 2
  • 34
  • 48
  • what will happen if I set the id to a string, as that function is from the ASIHttpRequest warpper.. I was thinking of changing but I wasnt sure if it would mess up the function. – C.Johns Aug 31 '11 at 21:16
  • actually dont answer that.. Im just going to make my own method with NSStrin *... thanks for the answer. – C.Johns Aug 31 '11 at 21:17
  • 1
    gets the function called from somewhere else, like in Interfacebuilder? If not you can overwrite it – Seega Aug 31 '11 at 21:26