1

ARCで必要な形式の文字列を取得するコードを記述し、EXC_BAD_ACCESS(code=2 address=0x100)を取得しました。

コードは次のとおりです。

NSString *inCook = [NSString stringWithFormat:@"GETAFREE_AUTH_HASH=%@; GETAFREE_USER_ID=%@", FRLAuthHash, FRLUserID];
NSLog(@"%@",inCook);

NSString *cookie1 = [[NSString alloc]init]; 
cookie1 = [NSString stringWithFormat:@"__utma=138759908.342110698.1339513728.1347619146.1347628547.51; __utmz=138759908.1339513728.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __atuvc=0%7C33%2C0%7C34%2C0%7C35%2C16%7C36%2C50%7C37; GETAFREE_REFERRAL_URL=https%3A%2F%2Fwww.freelancer.com%2Fusers%2Fonlogin.php; _chartbeat2=skcgjvrzgugx7kr0.1339513733066.1347628548930.00000000000001; WRUID=0; session2=6d909115a69f37ff641d798045d6f252; __qca=P0-624434954-1344332147605; FL_DASHBOARD_VIEWPAGE_4164248=sellerview; FL_DASHBOARD_TABINDEX_4164248=6; GETAFREE_LANGUAGE=en; __utmc=138759908; __utmb=138759908.1.10.1347628547; SpryMedia_DataTables_project_table_=%7B%22iCreate%22%3A1347628548100%2C%22iStart%22%3A0%2C%22iEnd%22%3A0%2C%22iLength%22%3A10%2C%22sFilter%22%3A%22%22%2C%22sFilterEsc%22%3Atrue%2C%22aaSorting%22%3A%5B%20%5B7%2C%22desc%22%5D%5D%2C%22aaSearchCols%22%3A%5B%20%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%5D%2C%22abVisCols%22%3A%5B%20false%2Ctrue%2Cfalse%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Cfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%2Cfalse%2Cfalse%2Cfalse%5D%7D"];

NSString *cookie2 = [NSString stringWithFormat:@"%@; %@",cookie1,inCook];

NSLog(@"%@",cookie2);

この行で EXC_BAD_ACCESS を取得しました。

    cookie1 = [NSString stringWithFormat:@"__utma=138759908.342110698.1339513728.1347619146.1347628547.51; __utmz=138759908.1339513728.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __atuvc=0%7C33%2C0%7C34%2C0%7C35%2C16%7C36%2C50%7C37; GETAFREE_REFERRAL_URL=https%3A%2F%2Fwww.freelancer.com%2Fusers%2Fonlogin.php; _chartbeat2=skcgjvrzgugx7kr0.1339513733066.1347628548930.00000000000001; WRUID=0; session2=6d909115a69f37ff641d798045d6f252; __qca=P0-624434954-1344332147605; FL_DASHBOARD_VIEWPAGE_4164248=sellerview; FL_DASHBOARD_TABINDEX_4164248=6; GETAFREE_LANGUAGE=en; __utmc=138759908; __utmb=138759908.1.10.1347628547; SpryMedia_DataTables_project_table_=%7B%22iCreate%22%3A1347628548100%2C%22iStart%22%3A0%2C%22iEnd%22%3A0%2C%22iLength%22%3A10%2C%22sFilter%22%3A%22%22%2C%22sFilterEsc%22%3Atrue%2C%22aaSorting%22%3A%5B%20%5B7%2C%22desc%22%5D%5D%2C%22aaSearchCols%22%3A%5B%20%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%5D%2C%22abVisCols%22%3A%5B%20false%2Ctrue%2Cfalse%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Cfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%2Cfalse%2Cfalse%2Cfalse%5D%7D"];

内部の値は、ウェブサイトからキャプチャしたものをコピーして貼り付けるだけです。

誰が私が間違ったことを言うことができますか?

どうもありがとう

4

3 に答える 3

3

その非常に長い文字列には、エスケープ%されていない文字が大量に含まれています。これらのいずれかがフォーマット文字列パターンに変換される場合、stringWithFormat:呼び出しから存在しないパラメーターを取得し、フォーマットされた文字列を構築しようとします。

使用しないでくださいstringWithFormat:。それが静的文字列であることを考えると、裸の@"....gobbledy-gook.....";.

于 2012-09-14T16:07:11.670 に答える
1

オンラインで

cookie1 = [NSString stringWithFormat:@"__utma=138759908.342110698.1339513728.1347619146.1347628547.51; __utmz=138759908.1339513728.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __atuvc=0%7C33%2C0%7C34%2C0%7C35%2C16%7C36%2C50%7C37; GETAFREE_REFERRAL_URL=https%3A%2F%2Fwww.freelancer.com%2Fusers%2Fonlogin.php; _chartbeat2=skcgjvrzgugx7kr0.1339513733066.1347628548930.00000000000001; WRUID=0; session2=6d909115a69f37ff641d798045d6f252; __qca=P0-624434954-1344332147605; FL_DASHBOARD_VIEWPAGE_4164248=sellerview; FL_DASHBOARD_TABINDEX_4164248=6; GETAFREE_LANGUAGE=en; __utmc=138759908; __utmb=138759908.1.10.1347628547; SpryMedia_DataTables_project_table_=%7B%22iCreate%22%3A1347628548100%2C%22iStart%22%3A0%2C%22iEnd%22%3A0%2C%22iLength%22%3A10%2C%22sFilter%22%3A%22%22%2C%22sFilterEsc%22%3Atrue%2C%22aaSorting%22%3A%5B%20%5B7%2C%22desc%22%5D%5D%2C%22aaSearchCols%22%3A%5B%20%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%5D%2C%22abVisCols%22%3A%5B%20false%2Ctrue%2Cfalse%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Cfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%2Cfalse%2Cfalse%2Cfalse%5D%7D"];

フォーマットされた文字列を求めています。「%」はフォーマット指定子です。つまり、結果の文字列で 1 パーセントを作成するには、 2 つの(のように)-stringWithFormatが必要です。それ以外の場合は、上記のリンクの指定子のいずれかを使用する必要があります。%%%

代わりに、単に文字列を割り当てることを意味しましたか?

cookie1 = @"__utma=138759908.342110698.1339513728.1347619146.1347628547.51; __utmz=138759908.1339513728.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __atuvc=0%7C33%2C0%7C34%2C0%7C35%2C16%7C36%2C50%7C37; GETAFREE_REFERRAL_URL=https%3A%2F%2Fwww.freelancer.com%2Fusers%2Fonlogin.php; _chartbeat2=skcgjvrzgugx7kr0.1339513733066.1347628548930.00000000000001; WRUID=0; session2=6d909115a69f37ff641d798045d6f252; __qca=P0-624434954-1344332147605; FL_DASHBOARD_VIEWPAGE_4164248=sellerview; FL_DASHBOARD_TABINDEX_4164248=6; GETAFREE_LANGUAGE=en; __utmc=138759908; __utmb=138759908.1.10.1347628547; SpryMedia_DataTables_project_table_=%7B%22iCreate%22%3A1347628548100%2C%22iStart%22%3A0%2C%22iEnd%22%3A0%2C%22iLength%22%3A10%2C%22sFilter%22%3A%22%22%2C%22sFilterEsc%22%3Atrue%2C%22aaSorting%22%3A%5B%20%5B7%2C%22desc%22%5D%5D%2C%22aaSearchCols%22%3A%5B%20%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%2C%5B%22%22%2Ctrue%5D%5D%2C%22abVisCols%22%3A%5B%20false%2Ctrue%2Cfalse%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Cfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%2Cfalse%2Cfalse%2Cfalse%5D%7D";
于 2012-09-14T16:15:13.227 に答える
0

文字列内の%シンボルがcookie1パーサーから外れています。実際のパーセント記号が必要な場合は、%%代わりに%.

あるいは、その文字列には他に何も入れていないので、のstringWithString代わりにメソッドを使用することもできますstringWithFormat。または単に@"your cookie"

于 2012-09-14T16:08:30.130 に答える