0

Xcode を 4.4.1 に更新すると、RestKit ライブラリの使用に対して 22 の警告が表示されます。エラーは次のようでした。

Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()

以下を置き換えて、18個の警告を修正しました。

%luと置き換えます%u

object->isaと置き換えますobject_getClass(object)

keyObject->isaと置き換えますobject_getClass(keyObject)

修正できない警告が 4 つ以上あります。以下に警告とその説明を示します。

ファイル名 1: RKManagedObjectMappingOperation.m 警告 Line1:

NSAssert(mapping, @"Attempted to connect relationship for keyPath '%@' without a relationship mapping defined.");

警告の説明 1:

more '%' conversations than data arguments

ファイル名 2: RKReachabilityObserver.m 警告行 2:

return [NSString stringWithFormat:@"<%@: %p host=%@ isReachabilityDetermined=%@ isMonitoringLocalWiFi=%d reachabilityFlags=%@>",
            NSStringFromClass([self class]), self, self.host, self.isReachabilityDetermined ? @"YES" : @"NO",
            self.isMonitoringLocalWiFi ? @"YES" : @"NO", [self reachabilityFlagsDescription]];

警告の説明 2:

format specifies type int but the argument has type NSString

ファイル名 3: JSONKit.m 警告行 3:

if(JK_EXPECT_F(((id)keys[idx])->isa != encodeState->fastClassLookup.stringClass) && JK_EXPECT_F([(id)keys[idx] isKindOfClass:[NSString class]] == NO)) { jk_encode_error(encodeState, @"Key must be a string object."); return(1); }

警告の説明 3:

Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()

ファイル名 4: NSManagedObject+ActiveRecord.m 警告行 4:

RKLogError(@"Property '%@' not found in %@ properties for %@", propertyName, [propDict count], NSStringFromClass(self));

警告の説明 4:

format specifies type id but the argument has type NSUInteger

修正方法は?

4

1 に答える 1

1

警告1:

NSAssert(mapping, @"Attempted to connect relationship for keyPath '%@' without a relationship mapping defined.");

になります

NSAssert(mapping, @"Attempted to connect relationship for keyPath '%@' without a relationship mapping defined.", <<put the corresponding keyPath here >> );

また

NSAssert(mapping, @"Attempted to connect relationship for a keyPath without a relationship mapping defined.");

「データ引数よりも'%'の会話が多い」と表示されているのは、プレースホルダー(この場合は%@)がありますが、それらを埋める引数がないことを意味します。したがって、引数を指定するか、プレースホルダーを削除してください。

警告2:

return [NSString stringWithFormat:@"<%@: %p host=%@ isReachabilityDetermined=%@ isMonitoringLocalWiFi=%d reachabilityFlags=%@>",
        NSStringFromClass([self class]), self, self.host, self.isReachabilityDetermined ? @"YES" : @"NO",
        self.isMonitoringLocalWiFi ? @"YES" : @"NO", [self reachabilityFlagsDescription]];

になります

return [NSString stringWithFormat:@"<%@: %p host=%@ isReachabilityDetermined=%@ isMonitoringLocalWiFi=%@ reachabilityFlags=%@>",
        NSStringFromClass([self class]), self, self.host, self.isReachabilityDetermined ? @"YES" : @"NO",
        self.isMonitoringLocalWiFi ? @"YES" : @"NO", [self reachabilityFlagsDescription]];

文字列引数を指定しているが整数のプレースホルダーがあるため、isMonitoringLocalWiFi=%dパーツが%@の代わりに取得されることに注意してください。%d

警告3:申し訳ありませんがこれであなたを助けることはできません。おそらく、コードを確認した後、更新を投稿します。

更新:変更してみてください

((id)keys[idx])->isa

object_getClass( ((id)keys[idx]) )

警告4:

RKLogError(@"Property '%@' not found in %@ properties for %@", propertyName, [propDict count], NSStringFromClass(self));

になります

RKLogError(@"Property '%@' not found in %d properties for %@", propertyName, [propDict count], NSStringFromClass(self));

整数またはこの場合はNSUInteger、つまり引数を指定するため、2番目のプレースホルダーはである必要が%dあります。%@[propDict count]

于 2012-09-08T00:19:44.443 に答える