如何用key的值替换objectAtIndex?

时间:2015-06-27 08:52:35

标签: ios nsmutablearray

我想使用objectAtIndex中的ValueForKey替换NSMutableArray。我已经尝试了以下代码,但没有用,它崩溃了,

[[students valueForKey:@"time"]replaceObjectAtIndex:indexPath.row withObject:dateString];

学生数组将包含:

(
{
    content = "\U0627\U064e\U0644\U0652\U062d\U064e\U0645\U0652\U062f\U064f \U0644\U0650\U0644\U0651\U0670\U0647\U0650 \U0627\U0644\U064e\U0651\U0630\U0650\U064a\U0652 \U0643\U064e\U0633\U064e\U0627\U0646\U0650\U064a\U0652 \U0647\U0670\U0630\U064e\U0627 (\U0627\U0644\U062b\U064e\U0651\U0648\U0652\U0628\U064e) \U0648\U064e\U0631\U064e\U0632\U064e\U0642\U064e\U0646\U0650\U064a\U0652\U0647\U0650 \U0645\U0650\U0646\U0652 \U063a\U064e\U064a\U0652\U0631\U0650 \U062d\U064e\U0648\U0652\U0644\U064d \U0645\U0650\U0651\U0646\U0650\U0651\U064a\U0652 \U0648\U064e\U0644\U0627\U064e \U0642\U064f\U0648\U064e\U0651\U0629\U064d.";
    heading = "GETTING DRESSED";
    id = 1;
    mp3 = 101;
    time = "11:14 AM";
    translation = "Praise be to Allah who has clothed me with this (garment) and provided it for me though I was powerless myself and incapable.";
    transliteration = "cvcvccvc.";
},
{
    content = "(\U0628\U0650\U0633\U0652\U0645\U0650 \U0627\U0644\U0644\U0651\U0670\U0647\U0650) \U0627\U064e\U0644\U0644\U0651\U0670\U0647\U064f\U0645\U064e\U0651 \U0625\U0650\U0646\U0650\U0651\U064a\U0652 \U0623\U064e\U0639\U064f\U0648\U0652\U0630\U064f \U0628\U0650\U0643\U064e \U0645\U0650\U0646\U064e \U0627\U0644\U0652\U062e\U064f\U0628\U0652\U062b\U0650 \U0648\U064e\U0627\U0644\U0652\U062e\U064e\U0628\U064e\U0627\U0626\U0650\U062b\U0650.";
    heading = "ENTERIGN THE RESTROOM";
    id = 3;
    mp3 = 103;
    time = "11:20 AM";
    translation = "(Before entering) [In the name of Allah]. (Then) Oh Allah, I seek protection in You from the male and female unclean spirits.";
    transliteration = "cvcvc";
},
{
    content = "\U0627\U064e\U0644\U0644\U0651\U0670\U0647\U064f\U0640\U0645\U064e\U0651 \U0623\U063a\U0650\U062b\U0652\U0646\U064e\U0627\U060c \U0627\U064e\U0644\U0644\U0651\U0670\U0647\U064f\U0645\U064e\U0651 \U0623\U063a\U0650\U062b\U0652\U0646\U064e\U0627\U060c \U0627\U064e\U0644\U0644\U0651\U0670\U0647\U064f\U0645\U064e\U0651 \U0623\U064e\U063a\U0650\U062b\U0652\U0646\U064e\U0627.";
    heading = "INVOCATIONS FOR RAIN";
    id = 6;
    mp3 = 106;
    time = "11:29 AM";
    translation = "O Allah, send us rain. O Allah, send us rain. O Allah, send us rain.O Allah, send us rain. O Allah, send us rain. O Allah, send us rain.";
    transliteration = "cvcvc";
}
)
请帮助一个人,我是新的呃。感谢。

2 个答案:

答案 0 :(得分:2)

NSMutableDictionary *dict = [students ObjectAtIndex:indexPath.row];
[dict setValue:dateString forKey:@"time"];
[students replaceObjectAtIndex:indexPath.row withObject:dict];

希望这会对你有所帮助

答案 1 :(得分:0)

[[studenrs objectAtIndex:indexPath.row] setObject:dateString forKey:@"time"]];