2017-12-15 38 views
0

デバッグ中に不変な辞書の値を置き換える必要があります。そのために 、私は不変とlldbコマンドでこれに値を設定しようとしているから、可変辞書作成:lldb経由でNSMutableDictionaryのオブジェクトを設定中にエラーが発生しました

po NSMutableDictionary *$tmp = [(NSDictionary *) immutableDict mutableCopy] 
po [$tmp setObject:@"object" forKey:@"key"] 

をしかしエラーでlldb失敗:

error: cannot initialize a parameter of type 'id<NSCopying> _Nonnull' with an rvalue of type 'NSString *' passing argument to parameter 'aKey' here

誰がどのように知っていますそれを修正する?

+0

あなたがimmutableDictを初期化する方法を教えてくださいできますか? –

+0

@HiteshSultaniyaそれはいくつかのアプリケーションに初期化され、私はブレークポイントでそれをキャッチ – svvoff

+0

大丈夫あなたはimmutableDictにそこにあるものを追加することはできますか? –

答えて

0

のTyrこのよう、lldbと

NSDictionary *dictTemp = [[NSDictionary alloc] initWithObjects:@[@"Value1",@"value2"] forKeys:@[@"Key1",@"Key2"]]; 
NSMutableDictionary *mutableDict = [[NSMutableDictionary alloc] initWithDictionary:dictTemp]; 

出力、

Printing description of mutableDict: 
{ 
    Key1 = Value1; 
    Key2 = value2; 
} 
(lldb) po [mutableDict setObject:@"Value3" forKey:@"Key3"] 
(lldb) po mutableDict 
{ 
    Key1 = Value1; 
    Key2 = value2; 
    Key3 = Value3; 
} 

(lldb) 
関連する問題