PLIST に保存した配列を読み込み、要素を変更して、PLIST に保存したいと考えています。
私の簡単なコードは次のとおりです。
NSArray *mathScoreArray;
NSNumber *score1 = [NSNumber numberWithInteger:score];
NSMutableArray *scoreArray1 = [[NSArray arrayWithArray:mathScoreArray] init];
[scoreArray1 replaceObjectAtIndex:4 withObject:score1];
[dictionary setObject:scoreArray1 forKey :@"mathScoreArray"];
[dictionary writeToFile:finalPath atomically:YES];
配列を変更するための「replaceObjectAtIndex」でエラーが発生します。これどうやってするの??
参考までに、私の plist は次のようになります。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>mathQues</key>
<integer>1</integer>
<key>mathScore</key>
<integer>0</integer>
<key>mathScoreArray</key>
<array>
<integer>10</integer>
<integer>20</integer>
<integer>30</integer>
<integer>40</integer>
<integer>50</integer>
</array>
</dict>
</plist>
問題を拡張すると、最終的には配列を 1 つ右にシフトし、[スタックのように] 新しい着信値を一番上に格納したいと思います。
ポインタをありがとう。ユーザー