0

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

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?

これは何を意味するのでしょうか?この問題を解決するにはどうすればよいですか?

ありがとう、

ジェームズ

4

4 に答える 4

4

辞書の初期化で文字列をフォーマットしようとしていますが、フォーマットは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];
于 2011-09-08T19:57:55.840 に答える
2

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

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];
于 2011-09-08T19:56:27.127 に答える
1

引数がありません。nil を含む合計 8 つの引数を数えます。これは、キーと値のペアの 1 つが完全ではないことを意味します。

于 2011-09-08T19:55:15.390 に答える
1

最初に文字列を作成してみてください:

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

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

于 2011-09-08T19:56:10.673 に答える