adba / OpenWeatherMapAPI

iOS api classes for openweathermap.org
MIT License
256 stars 68 forks source link

Not called #11

Closed kristersj closed 10 years ago

kristersj commented 10 years ago

Hi,

Is there any reason why the block method is never called when I create a request? I do it in two viewControllers, the first one and then in another one. It works in the first one but in the second one the block code never gets called. Is there some kind of a issue and I have to call it differently?

Thanks, Kristers.

Ge0rges commented 10 years ago

Could you post your code and clarify your question please?

Sent from my iPhone

On Dec 10, 2013, at 12:47 PM, krampis notifications@github.com wrote:

Hi,

Is there any reason why the block method is never called when I create a request? I do it in two viewControllers, the first one and then in another one. It works in the first one but in the second one the block code never gets called. Is there some kind of a issue and I have to call it differently?

Thanks, Kristers.

— Reply to this email directly or view it on GitHub.

kristersj commented 10 years ago

@Ge0rges ok. So I call this

OWMWeatherAPI *weatherAPI = [[OWMWeatherAPI alloc] initWithAPIKey:@"MY_API_KEY"];
[weatherAPI setTemperatureFormat:kOWMTempCelcius];

[weatherAPI currentWeatherByCityName:[city stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
                        withCallback:^(NSError *error, NSDictionary *result) {

                           //here I would do smth with the data I got but this block never gets called.
}];

That is my question. This works in one class, but in the class where I try to use it again the block never gets called. Do I need to somehow clear the last used OWMWeatherAPI to make this one work?

Ge0rges commented 10 years ago

Possibly yes.

Sent from my iPhone

On Dec 10, 2013, at 9:25 PM, krampis notifications@github.com wrote:

@Ge0rges ok. So I call this

OWMWeatherAPI *weatherAPI = [[OWMWeatherAPI alloc] initWithAPIKey:@"MY_API_KEY"];

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"celsius"]) { [weatherAPI setTemperatureFormat:kOWMTempCelcius]; } else { [weatherAPI setTemperatureFormat:kOWMTempFahrenheit]; }

[weatherAPI currentWeatherByCityName:[city stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] withCallback:^(NSError error, NSDictionary result) {

                       //here I would do smth with the data I got but this block never gets called.

}]; That is my question. This works in one class, but in the class where I try to use it again the block never gets called. Do I need to somehow clear the last used OWMWeatherAPI to make this one work?

— Reply to this email directly or view it on GitHub.

kristersj commented 10 years ago

@Ge0rges do you have any idea how?

Ge0rges commented 10 years ago

What you should do is this:

.h:

OMWeatherAPI *weatherAPI;

.m

-(void)viewDidLoad {

OWMWeatherAPI *weatherAPI = [[OWMWeatherAPI alloc] initWithAPIKey:@"MY_API_KEY"];

}

then wherever you want to use it just type:

[weatherAPI setTemperatureFormat:kOWMTempCelcius];

as if you where using it normaly.

kristersj commented 10 years ago

It still doesn't get called... any other ideas?

Ge0rges commented 10 years ago

Hmm how do you know the method is actually working?

Sent from my iPhone

On Dec 12, 2013, at 3:41 PM, krampis notifications@github.com wrote:

It still doesn't get called... any other ideas?

— Reply to this email directly or view it on GitHub.

kristersj commented 10 years ago

Yes. I have it setup in two view controllers. The first that shows when opening the app - it works, when I go to the next view I have the same code, doesn't work.

Ge0rges commented 10 years ago

Ah. I see show me the code for the first view controller please

Sent from my iPhone

On Dec 12, 2013, at 3:51 PM, krampis notifications@github.com wrote:

Yes. I have it setup in two view controllers. The first that shows when opening the app - it works, when I go to the next view I have the same code, doesn't work.

— Reply to this email directly or view it on GitHub.

kristersj commented 10 years ago

Just fixed it. I don't know why but it had some problems because I used it from a block or something. Ahh, frustrating but thanks for the ideas!

Ge0rges commented 10 years ago

Glad I could help!

Sent from my iPhone

On Dec 12, 2013, at 4:13 PM, krampis notifications@github.com wrote:

GitHub.