質問

次のコードを入れました...;

NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
@"Hello,\n You've just received a new message from the iDHSB iPhone App.\n Here it is: %@",field.text,     
kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];

...そして、私はnsexceptionエラーを受けます。

*** WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate:     
<NSInvalidArgumentException> +[NSDictionary dictionaryWithObjectsAndKeys:]: second object of each pair must be non-nil.  Or, did  
you forget to nil-terminate your parameter list?

これは何を意味するのでしょうか?この問題を修正するために私は何をしなければなりませんか?

ありがとう、

ジェームズ

役に立ちましたか?

解決

辞書の初期化で文字列をフォーマットしようとしていますが、形式が object, key, object, key, etc... 。修正するには、透明度のために別の行にフォーマットされた文字列を作成してから、オブジェクトとキーの一部として追加してみてください。

NSString *message = [NSString stringWithFormat:@"Hello,\n You've just received a new message from the iDHSB iPhone App.\n Here it is: %@",
                                                 field.text];
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:
                              @"text/plain", kSKPSMTPPartContentTypeKey,
                              message, kSKPSMTPPartMessageKey,
                              @"8bit", kSKPSMTPPartContentTransferEncodingKey,nil];

他のヒント

多分あなたはこのようなことを意味しました:

NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain", kSKPSMTPPartContentTypeKey, [NSString stringWithFormat:@"Hello,\n You've just received a new message from the iDHSB iPhone App.\n Here it is: %@",field.text], kSKPSMTPPartMessageKey, @"8bit", kSKPSMTPPartContentTransferEncodingKey,nil];

あなたは議論を逃しています。 Nilを含む8つの合計引数を数えます。つまり、キー値のペアの1つが完全ではないことを意味します。

firsty create stringを試してください:

NSString *partMessageKey = [NSString stringWithFormat:@"Hello,\n You've just received a new message from the iDHSB iPhone App.\n Here it is: %@",field.text];

次に、この文字列をオブジェクトとして辞書に配置します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top