nilオブジェクトを使用すると、オブジェクトが有効でない場合に返すアクセサーを記述できます。
- (Weather *)howsTheWeather
{
    if (![WeatherNetwork isAvailable]) {
        return nil;
    }
    Weather *weatherNow = [WeatherNetwork getWeather];
    return weatherNow;
}
緯度と経度を保持するために a CLLocationCoordinate2D、 aでこれを行いたいと思います。struct私はこれを試しました:
- (CLLocationCoordinate2D)coordinate
{
    CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(self.latitude, self.longitude);
    if (!CLLocationCoordinate2DIsValid(coord)) {
        return nil;
    }
    return coord;
}
しかし、コンパイラは「互換性のない結果型 'CLLocationCoordinate2D' を持つ関数から 'void *' を返す」と文句を言います。
このような状況に対処する最善の方法は何ですか? 別のメソッドを書くことを考えていました-(BOOL)isLocationValid:(CLLocationCoordinate2D)coordinate。これに対処するより良い方法はありますか?