开发者

Start one function after another finished iphone

开发者 https://www.devze.com 2022-12-24 09:20 出处:网络
I have a function that updates the gps coordinate lat and long then sends a tweet with the lat and long info attached. I want the functio开发者_如何学编程n to wait until the lat and long are filled be

I have a function that updates the gps coordinate lat and long then sends a tweet with the lat and long info attached. I want the functio开发者_如何学编程n to wait until the lat and long are filled before the tweet goes through but it seems to do both at the same time so the lat and long don't get filled in. How do I make the gps location update first?


Have you tried decoupling the 'tweet' function from the lat and long function and have it take in lat and long as parameters? That way, in your lat and long function you set two variables, and then pass them to the tweet function, therefore it won't call it until you call it with the right data.

Something like:

- (void) getLatLong{
    int latitude;
    int longitude;

    latitude= MyClass getLat;
    latitude= MyClass getLong;

    MyClass tweet:latitude:longitude;
}

- (void) tweet:(int) latitude:(int) longitude{
    // send tweet
}
0

精彩评论

暂无评论...
验证码 换一张
取 消