@property (strong,nonatomic) NSString* test1;
.m文件
-(void)doStuff
{
userLocationManager = [[CLLocationManager alloc]]init]; //has been synthesized already
userLocationManager.delegate = self;
userLocationManager.distanceFilter = kCLDistanceFilterNone;
userLocationManager.desiredAccuracy = kCLLocationAccuracyBest;
[userLocationManager startUpdatingLocation];
NSLog(@"%@",self.test1); //logs (null)
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
self.test1 = @"Hello!";
[userLocationManager stopUpdatingLocation];
}
隨後的屬性的類,我有一個初始化的LocationManager等,一類我最終打電話給locationManager:didUpdateLocations.
然後我在這個方法中做一個簡單的[email protected]"Hello"
,只是爲了看看我能否從這個函數中分配字符串。在另一種方法,我NSLog self.test1
,看看它是否更新,但我得到(null)
,在控制檯。是locationManager:didUpdateLocations
異步還是什麼? 謝謝! 〜Carpetfizz
編輯:添加更多的代碼,使問題更加清晰。請原諒我從另一臺計算機上覆制代碼時出現任何語法錯誤。它編譯好。
你能把更多的信息?它應該工作,它不是異步的。 –
@AntonioMG我會試試! – Carpetfizz