菜鸟教程小白 发表于 2022-12-13 14:29:53

ios - 如何在自定义 UITableViewCell 中的 Dictionary 中显示数据?


                                            <p><p>我正在使用 <code>AFNetworking 3.0</code>。</p>

<p>在 ViewController 中,我在每个单元格中显示了多个专业标题。点击特定单元格后,我得到了服务器的响应,如下所示:</p>

<pre><code>[{&#34;dp&#34;:{&#34;id&#34;:0,&#34;qualification&#34;:&#34;MD(Doctor)&#34;,&#34;reg_id&#34;:0,&#34;specialization1&#34;:&#34;Orthopaedics&#34;,&#34;specialization2&#34;:&#34;Dermatologist&#34;,&#34;specialization3&#34;:&#34;Neurology&#34;,&#34;url&#34;:&#34;www.batras.com&#34;},&#34;ds&#34;:{&#34;city&#34;:&#34;agiripalle&#34;,&#34;consultation_fee&#34;:450,&#34;contact_no&#34;:&#34;1234567890&#34;,&#34;country&#34;:&#34;India&#34;,&#34;id&#34;:18,&#34;organization_name&#34;:&#34;Batra&#34;,&#34;pin_code&#34;:&#34;411052&#34;,&#34;reg_id&#34;:0,&#34;state&#34;:&#34;andhra pradesh&#34;,&#34;street_name&#34;:&#34;jhbfahjf&#34;,&#34;wellness_flag&#34;:false},&#34;reg&#34;:{&#34;mobile_no&#34;:0,&#34;name&#34;:&#34;Batra&#34;,&#34;profile_id&#34;:0,&#34;reg_id&#34;:157,&#34;wellness_id&#34;:&#34;251215782521&#34;}},{&#34;dp&#34;:{&#34;id&#34;:0,&#34;qualification&#34;:&#34;MD(Doctor)&#34;,&#34;reg_id&#34;:0,&#34;specialization1&#34;:&#34;Orthopaedics&#34;,&#34;specialization2&#34;:&#34;Dermatologist&#34;,&#34;specialization3&#34;:&#34;Neurology&#34;,&#34;url&#34;:&#34;www.batras.com&#34;},&#34;ds&#34;:{&#34;city&#34;:&#34;anur&#34;,&#34;consultation_fee&#34;:458,&#34;contact_no&#34;:&#34;1234567898&#34;,&#34;country&#34;:&#34;India&#34;,&#34;id&#34;:19,&#34;organization_name&#34;:&#34;Danny&#34;,&#34;pin_code&#34;:&#34;411052&#34;,&#34;reg_id&#34;:0,&#34;state&#34;:&#34;himachal pradesh&#34;,&#34;street_name&#34;:&#34;afafwfw&#34;,&#34;wellness_flag&#34;:false},&#34;reg&#34;:{&#34;mobile_no&#34;:0,&#34;name&#34;:&#34;Batra&#34;,&#34;profile_id&#34;:0,&#34;reg_id&#34;:157,&#34;wellness_id&#34;:&#34;251215782521&#34;}},{&#34;dp&#34;:{&#34;id&#34;:0,&#34;qualification&#34;:&#34;MD(Doctor)&#34;,&#34;reg_id&#34;:0,&#34;specialization1&#34;:&#34;Orthopaedics&#34;,&#34;specialization2&#34;:&#34;Dermatologist&#34;,&#34;specialization3&#34;:&#34;Neurology&#34;,&#34;url&#34;:&#34;www.batras.com&#34;},&#34;ds&#34;:{&#34;city&#34;:&#34;pabal&#34;,&#34;consultation_fee&#34;:500,&#34;contact_no&#34;:&#34;4512451252&#34;,&#34;country&#34;:&#34;India&#34;,&#34;id&#34;:20,&#34;organization_name&#34;:&#34;Org Name&#34;,&#34;pin_code&#34;:&#34;411052&#34;,&#34;reg_id&#34;:0,&#34;state&#34;:&#34;maharashtra&#34;,&#34;street_name&#34;:&#34;afawafww&#34;,&#34;wellness_flag&#34;:false},&#34;reg&#34;:{&#34;mobile_no&#34;:0,&#34;name&#34;:&#34;Batra&#34;,&#34;profile_id&#34;:0,&#34;reg_id&#34;:157,&#34;wellness_id&#34;:&#34;251215782521&#34;}},{&#34;dp&#34;:{&#34;id&#34;:0,&#34;qualification&#34;:&#34;MD(Doctor)&#34;,&#34;reg_id&#34;:0,&#34;specialization1&#34;:&#34;Orthopaedics&#34;,&#34;specialization2&#34;:&#34;Dermatologist&#34;,&#34;specialization3&#34;:&#34;Neurology&#34;,&#34;specialization4&#34;:&#34;Gynecologist&#34;,&#34;url&#34;:&#34;danny.com&#34;},&#34;ds&#34;:{&#34;city&#34;:&#34;bumlitan&#34;,&#34;consultation_fee&#34;:504,&#34;contact_no&#34;:&#34;1234567898&#34;,&#34;country&#34;:&#34;India&#34;,&#34;id&#34;:21,&#34;organization_name&#34;:&#34;Danny&#34;,&#34;pin_code&#34;:&#34;411052&#34;,&#34;reg_id&#34;:0,&#34;state&#34;:&#34;andaman and nicobar islands&#34;,&#34;street_name&#34;:&#34;East Street&#34;,&#34;wellness_flag&#34;:false},&#34;reg&#34;:{&#34;mobile_no&#34;:0,&#34;name&#34;:&#34;Danny&#34;,&#34;profile_id&#34;:0,&#34;reg_id&#34;:167,&#34;wellness_id&#34;:&#34;311220165848&#34;}},{&#34;dp&#34;:{&#34;id&#34;:0,&#34;qualification&#34;:&#34;MD(Doctor)&#34;,&#34;reg_id&#34;:0,&#34;specialization1&#34;:&#34;Orthopaedics&#34;,&#34;specialization2&#34;:&#34;Dermatologist&#34;,&#34;specialization3&#34;:&#34;Neurology&#34;,&#34;specialization4&#34;:&#34;Gynecologist&#34;,&#34;url&#34;:&#34;danny.com&#34;},&#34;ds&#34;:{&#34;city&#34;:&#34;amtala&#34;,&#34;consultation_fee&#34;:451,&#34;contact_no&#34;:&#34;1234567898&#34;,&#34;country&#34;:&#34;India&#34;,&#34;id&#34;:22,&#34;organization_name&#34;:&#34;Danny&#34;,&#34;pin_code&#34;:&#34;411052&#34;,&#34;reg_id&#34;:0,&#34;state&#34;:&#34;assam&#34;,&#34;street_name&#34;:&#34;West&#34;,&#34;wellness_flag&#34;:false},&#34;reg&#34;:{&#34;mobile_no&#34;:0,&#34;name&#34;:&#34;Danny&#34;,&#34;profile_id&#34;:0,&#34;reg_id&#34;:167,&#34;wellness_id&#34;:&#34;311220165848&#34;}},{&#34;dp&#34;:{&#34;id&#34;:0,&#34;qualification&#34;:&#34;MD(Doctor)&#34;,&#34;reg_id&#34;:0,&#34;specialization1&#34;:&#34;Orthopaedics&#34;,&#34;specialization2&#34;:&#34;Dermatologist&#34;,&#34;specialization3&#34;:&#34;Neurology&#34;,&#34;specialization4&#34;:&#34;Gynecologist&#34;,&#34;url&#34;:&#34;danny.com&#34;},&#34;ds&#34;:{&#34;city&#34;:&#34;hala&#34;,&#34;consultation_fee&#34;:541,&#34;contact_no&#34;:&#34;1234567890&#34;,&#34;country&#34;:&#34;India&#34;,&#34;id&#34;:23,&#34;organization_name&#34;:&#34;Danny Clinic&#34;,&#34;pin_code&#34;:&#34;411123&#34;,&#34;reg_id&#34;:0,&#34;state&#34;:&#34;chandigarh&#34;,&#34;street_name&#34;:&#34;Chandigarh&#34;,&#34;wellness_flag&#34;:false},&#34;reg&#34;:{&#34;mobile_no&#34;:0,&#34;name&#34;:&#34;Danny&#34;,&#34;profile_id&#34;:0,&#34;reg_id&#34;:167,&#34;wellness_id&#34;:&#34;311220165848&#34;}}]
</code></pre>

<p>之后,我按以下方式处理该响应:</p>

<pre><code>NSLog(@&#34;Response from specialization server:%@&#34;, [ initWithData:responseObject encoding:NSUTF8StringEncoding]);
NSArray *ResponseArray = ;
if (ResponseArray.count &gt;0)
{
    _spclarr = ;
    NSLog(@&#34;special_array : %@&#34;,_spclarr);
    _spclstr=;
    NSUserDefaults *prefs = ;

    // saving an NSString
    ;
    ;
}
;
} failure:^(NSURLSessionTask *operation, NSError *error)
          {
   // If Error occure, then this is AlertController Appear
                  NSLog(@&#34;Error: %@&#34;, error);
</code></pre>

<p>在下一个 View 中:</p>

<pre><code>- (void)viewDidLoad {
    ;
            NSUserDefaults *prefs = ;
    NSString *s = ;
    NSLog(@&#34;spcl: %@&#34;,s);
    menuItems=;
    NSLog(@&#34;menu: %@&#34;,menuItems);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return ;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @&#34;Doctordetail&#34;;
            DoctorDetailTableViewCell *cell = ;
            NSDictionary *content = ;
    NSLog(@&#34;content: %@&#34;,content);
return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@&#34;%ld&#34;,(long)indexPath.row);
            NSDictionary *content = ;
    NSLog(@&#34;Cell Clicked: %@&#34;,menuItems);
    NSLog(@&#34;content2: %@&#34;,content);
    }
</code></pre>

<p>当我在模拟器上运行应用程序时,它可以工作。当我单击特定单元格时,日志会打印该单元格的数据。</p>

<p>这里是菜单项:</p>

<pre><code>menu: (
    &#34;(\n      {\n      dp =         {\n            id = 0;\n            qualification = \&#34;MD(Doctor)\&#34;;\n            \&#34;reg_id\&#34; = 0;\n            specialization1 = Orthopaedics;\n            specialization2 = Dermatologist;\n            specialization3 = Neurology;\n            url = \&#34;www.batras.com\&#34;;\n      };\n      ds =         {\n            city = agiripalle;\n            \&#34;consultation_fee\&#34; = 450;\n            \&#34;contact_no\&#34; = 1234567890;\n            country = India;\n            id = 18;\n            \&#34;organization_name\&#34; = Batra;\n            \&#34;pin_code\&#34; = 411052;\n            \&#34;reg_id\&#34; = 0;\n            state = \&#34;andhra pradesh\&#34;;\n            \&#34;street_name\&#34; = jhbfahjf;\n            \&#34;wellness_flag\&#34; = 0;\n      };\n      reg =         {\n            \&#34;mobile_no\&#34; = 0;\n            name = Batra;\n            \&#34;profile_id\&#34; = 0;\n            \&#34;reg_id\&#34; = 157;\n            \&#34;wellness_id\&#34; = 251215782521;\n      };\n    }&#34;,
    &#34;\n      {\n      dp =         {\n            id = 0;\n            qualification = \&#34;MD(Doctor)\&#34;;\n            \&#34;reg_id\&#34; = 0;\n            specialization1 = Orthopaedics;\n            specialization2 = Dermatologist;\n            specialization3 = Neurology;\n            url = \&#34;www.batras.com\&#34;;\n      };\n      ds =         {\n            city = anur;\n            \&#34;consultation_fee\&#34; = 458;\n            \&#34;contact_no\&#34; = 1234567898;\n            country = India;\n            id = 19;\n            \&#34;organization_name\&#34; = Danny;\n            \&#34;pin_code\&#34; = 411052;\n            \&#34;reg_id\&#34; = 0;\n            state = \&#34;himachal pradesh\&#34;;\n            \&#34;street_name\&#34; = afafwfw;\n            \&#34;wellness_flag\&#34; = 0;\n      };\n      reg =         {\n            \&#34;mobile_no\&#34; = 0;\n            name = Batra;\n            \&#34;profile_id\&#34; = 0;\n            \&#34;reg_id\&#34; = 157;\n            \&#34;wellness_id\&#34; = 251215782521;\n      };\n    }&#34;,
    &#34;\n      {\n      dp =         {\n            id = 0;\n            qualification = \&#34;MD(Doctor)\&#34;;\n            \&#34;reg_id\&#34; = 0;\n            specialization1 = Orthopaedics;\n            specialization2 = Dermatologist;\n            specialization3 = Neurology;\n            url = \&#34;www.batras.com\&#34;;\n      };\n      ds =         {\n            city = pabal;\n            \&#34;consultation_fee\&#34; = 500;\n            \&#34;contact_no\&#34; = 4512451252;\n            country = India;\n            id = 20;\n            \&#34;organization_name\&#34; = \&#34;Org Name\&#34;;\n            \&#34;pin_code\&#34; = 411052;\n            \&#34;reg_id\&#34; = 0;\n            state = maharashtra;\n            \&#34;street_name\&#34; = afawafww;\n            \&#34;wellness_flag\&#34; = 0;\n      };\n      reg =         {\n            \&#34;mobile_no\&#34; = 0;\n            name = Batra;\n            \&#34;profile_id\&#34; = 0;\n            \&#34;reg_id\&#34; = 157;\n            \&#34;wellness_id\&#34; = 251215782521;\n      };\n    }&#34;,
    &#34;\n      {\n      dp =         {\n            id = 0;\n            qualification = \&#34;MD(Doctor)\&#34;;\n            \&#34;reg_id\&#34; = 0;\n            specialization1 = Orthopaedics;\n            specialization2 = Dermatologist;\n            specialization3 = Neurology;\n            specialization4 = Gynecologist;\n            url = \&#34;danny.com\&#34;;\n      };\n      ds =         {\n            city = bumlitan;\n            \&#34;consultation_fee\&#34; = 504;\n            \&#34;contact_no\&#34; = 1234567898;\n            country = India;\n            id = 21;\n            \&#34;organization_name\&#34; = Danny;\n            \&#34;pin_code\&#34; = 411052;\n            \&#34;reg_id\&#34; = 0;\n            state = \&#34;andaman and nicobar islands\&#34;;\n            \&#34;street_name\&#34; = \&#34;East Street\&#34;;\n            \&#34;wellness_flag\&#34; = 0;\n      };\n      reg =         {\n            \&#34;mobile_no\&#34; = 0;\n            name = Danny;\n            \&#34;profile_id\&#34; = 0;\n            \&#34;reg_id\&#34; = 167;\n            \&#34;wellness_id\&#34; = 311220165848;\n      };\n    }&#34;,
    &#34;\n      {\n      dp =         {\n            id = 0;\n            qualification = \&#34;MD(Doctor)\&#34;;\n            \&#34;reg_id\&#34; = 0;\n            specialization1 = Orthopaedics;\n            specialization2 = Dermatologist;\n            specialization3 = Neurology;\n            specialization4 = Gynecologist;\n            url = \&#34;danny.com\&#34;;\n      };\n      ds =         {\n            city = amtala;\n            \&#34;consultation_fee\&#34; = 451;\n            \&#34;contact_no\&#34; = 1234567898;\n            country = India;\n            id = 22;\n            \&#34;organization_name\&#34; = Danny;\n            \&#34;pin_code\&#34; = 411052;\n            \&#34;reg_id\&#34; = 0;\n            state = assam;\n            \&#34;street_name\&#34; = West;\n            \&#34;wellness_flag\&#34; = 0;\n      };\n      reg =         {\n            \&#34;mobile_no\&#34; = 0;\n            name = Danny;\n            \&#34;profile_id\&#34; = 0;\n            \&#34;reg_id\&#34; = 167;\n            \&#34;wellness_id\&#34; = 311220165848;\n      };\n    }&#34;,
    &#34;\n      {\n      dp =         {\n            id = 0;\n            qualification = \&#34;MD(Doctor)\&#34;;\n            \&#34;reg_id\&#34; = 0;\n            specialization1 = Orthopaedics;\n            specialization2 = Dermatologist;\n            specialization3 = Neurology;\n            specialization4 = Gynecologist;\n            url = \&#34;danny.com\&#34;;\n      };\n      ds =         {\n            city = hala;\n            \&#34;consultation_fee\&#34; = 541;\n            \&#34;contact_no\&#34; = 1234567890;\n            country = India;\n            id = 23;\n            \&#34;organization_name\&#34; = \&#34;Danny Clinic\&#34;;\n            \&#34;pin_code\&#34; = 411123;\n            \&#34;reg_id\&#34; = 0;\n            state = chandigarh;\n            \&#34;street_name\&#34; = Chandigarh;\n            \&#34;wellness_flag\&#34; = 0;\n      };\n      reg =         {\n            \&#34;mobile_no\&#34; = 0;\n            name = Danny;\n            \&#34;profile_id\&#34; = 0;\n            \&#34;reg_id\&#34; = 167;\n            \&#34;wellness_id\&#34; = 311220165848;\n      };\n    }\n)&#34;
)
</code></pre>

<p>和内容:</p>

<pre><code>content: (
      {
      dp =         {
            id = 0;
            qualification = &#34;MD(Doctor)&#34;;
            &#34;reg_id&#34; = 0;
            specialization1 = Orthopaedics;
            specialization2 = Dermatologist;
            specialization3 = Neurology;
            url = &#34;www.batras.com&#34;;
      };
      ds =         {
            city = agiripalle;
            &#34;consultation_fee&#34; = 450;
            &#34;contact_no&#34; = 1234567890;
            country = India;
            id = 18;
            &#34;organization_name&#34; = Batra;
            &#34;pin_code&#34; = 411052;
            &#34;reg_id&#34; = 0;
            state = &#34;andhra pradesh&#34;;
            &#34;street_name&#34; = jhbfahjf;
            &#34;wellness_flag&#34; = 0;
      };
      reg =         {
            &#34;mobile_no&#34; = 0;
            name = Batra;
            &#34;profile_id&#34; = 0;
            &#34;reg_id&#34; = 157;
            &#34;wellness_id&#34; = 251215782521;
      };
    }
2016-12-21 13:52:48.184 Wellness_24x7 content:
      {
      dp =         {
            id = 0;
            qualification = &#34;MD(Doctor)&#34;;
            &#34;reg_id&#34; = 0;
            specialization1 = Orthopaedics;
            specialization2 = Dermatologist;
            specialization3 = Neurology;
            url = &#34;www.batras.com&#34;;
      };
      ds =         {
            city = anur;
            &#34;consultation_fee&#34; = 458;
            &#34;contact_no&#34; = 1234567898;
            country = India;
            id = 19;
            &#34;organization_name&#34; = Danny;
            &#34;pin_code&#34; = 411052;
            &#34;reg_id&#34; = 0;
            state = &#34;himachal pradesh&#34;;
            &#34;street_name&#34; = afafwfw;
            &#34;wellness_flag&#34; = 0;
      };
      reg =         {
            &#34;mobile_no&#34; = 0;
            name = Batra;
            &#34;profile_id&#34; = 0;
            &#34;reg_id&#34; = 157;
            &#34;wellness_id&#34; = 251215782521;
      };
    }
2016-12-21 13:52:48.185 Wellness_24x7 content:
      {
      dp =         {
            id = 0;
            qualification = &#34;MD(Doctor)&#34;;
            &#34;reg_id&#34; = 0;
            specialization1 = Orthopaedics;
            specialization2 = Dermatologist;
            specialization3 = Neurology;
            url = &#34;www.batras.com&#34;;
      };
      ds =         {
            city = pabal;
            &#34;consultation_fee&#34; = 500;
            &#34;contact_no&#34; = 4512451252;
            country = India;
            id = 20;
            &#34;organization_name&#34; = &#34;Org Name&#34;;
            &#34;pin_code&#34; = 411052;
            &#34;reg_id&#34; = 0;
            state = maharashtra;
            &#34;street_name&#34; = afawafww;
            &#34;wellness_flag&#34; = 0;
      };
      reg =         {
            &#34;mobile_no&#34; = 0;
            name = Batra;
            &#34;profile_id&#34; = 0;
            &#34;reg_id&#34; = 157;
            &#34;wellness_id&#34; = 251215782521;
      };
    }
2016-12-21 13:52:48.187 Wellness_24x7 content:
      {
      dp =         {
            id = 0;
            qualification = &#34;MD(Doctor)&#34;;
            &#34;reg_id&#34; = 0;
            specialization1 = Orthopaedics;
            specialization2 = Dermatologist;
            specialization3 = Neurology;
            specialization4 = Gynecologist;
            url = &#34;danny.com&#34;;
      };
      ds =         {
            city = bumlitan;
            &#34;consultation_fee&#34; = 504;
            &#34;contact_no&#34; = 1234567898;
            country = India;
            id = 21;
            &#34;organization_name&#34; = Danny;
            &#34;pin_code&#34; = 411052;
            &#34;reg_id&#34; = 0;
            state = &#34;andaman and nicobar islands&#34;;
            &#34;street_name&#34; = &#34;East Street&#34;;
            &#34;wellness_flag&#34; = 0;
      };
      reg =         {
            &#34;mobile_no&#34; = 0;
            name = Danny;
            &#34;profile_id&#34; = 0;
            &#34;reg_id&#34; = 167;
            &#34;wellness_id&#34; = 311220165848;
      };
    }
2016-12-21 13:52:52.862 Wellness_24x7 content:
      {
      dp =         {
            id = 0;
            qualification = &#34;MD(Doctor)&#34;;
            &#34;reg_id&#34; = 0;
            specialization1 = Orthopaedics;
            specialization2 = Dermatologist;
            specialization3 = Neurology;
            specialization4 = Gynecologist;
            url = &#34;danny.com&#34;;
      };
      ds =         {
            city = amtala;
            &#34;consultation_fee&#34; = 451;
            &#34;contact_no&#34; = 1234567898;
            country = India;
            id = 22;
            &#34;organization_name&#34; = Danny;
            &#34;pin_code&#34; = 411052;
            &#34;reg_id&#34; = 0;
            state = assam;
            &#34;street_name&#34; = West;
            &#34;wellness_flag&#34; = 0;
      };
      reg =         {
            &#34;mobile_no&#34; = 0;
            name = Danny;
            &#34;profile_id&#34; = 0;
            &#34;reg_id&#34; = 167;
            &#34;wellness_id&#34; = 311220165848;
      };
    }
2016-12-21 13:52:52.962 Wellness_24x7 content:
      {
      dp =         {
            id = 0;
            qualification = &#34;MD(Doctor)&#34;;
            &#34;reg_id&#34; = 0;
            specialization1 = Orthopaedics;
            specialization2 = Dermatologist;
            specialization3 = Neurology;
            specialization4 = Gynecologist;
            url = &#34;danny.com&#34;;
      };
      ds =         {
            city = hala;
            &#34;consultation_fee&#34; = 541;
            &#34;contact_no&#34; = 1234567890;
            country = India;
            id = 23;
            &#34;organization_name&#34; = &#34;Danny Clinic&#34;;
            &#34;pin_code&#34; = 411123;
            &#34;reg_id&#34; = 0;
            state = chandigarh;
            &#34;street_name&#34; = Chandigarh;
            &#34;wellness_flag&#34; = 0;
      };
      reg =         {
            &#34;mobile_no&#34; = 0;
            name = Danny;
            &#34;profile_id&#34; = 0;
            &#34;reg_id&#34; = 167;
            &#34;wellness_id&#34; = 311220165848;
      };
    }
)
2016-12-21 13:52:53.918 Wellness_24x7 content: (
      {
      dp =         {
            id = 0;
            qualification = &#34;MD(Doctor)&#34;;
            &#34;reg_id&#34; = 0;
            specialization1 = Orthopaedics;
            specialization2 = Dermatologist;
            specialization3 = Neurology;
            url = &#34;www.batras.com&#34;;
      };
      ds =         {
            city = agiripalle;
            &#34;consultation_fee&#34; = 450;
            &#34;contact_no&#34; = 1234567890;
            country = India;
            id = 18;
            &#34;organization_name&#34; = Batra;
            &#34;pin_code&#34; = 411052;
            &#34;reg_id&#34; = 0;
            state = &#34;andhra pradesh&#34;;
            &#34;street_name&#34; = jhbfahjf;
            &#34;wellness_flag&#34; = 0;
      };
      reg =         {
            &#34;mobile_no&#34; = 0;
            name = Batra;
            &#34;profile_id&#34; = 0;
            &#34;reg_id&#34; = 157;
            &#34;wellness_id&#34; = 251215782521;
      };
    }
</code></pre>

<p>但是<strong>我的问题是</strong>,它没有显示在<code>UITableViewCell</code></p>

<p>我尝试如下方式显示它:</p>

<pre><code>valueForKey:@&#34;qualification&#34;]];
</code></pre>

<p>还有
<code>valueForKey:@"qualification"]]];</code></p>

<p>但它给了我这样的错误:</p>

<blockquote>
<p>Terminating app due to uncaught exception &#39;NSInvalidArgumentException&#39;, reason: &#39;-: unrecognized selector sent to instance 0x7a07c600&#39;</p>
</blockquote>

<p>我没听懂,我错了。</p>

<p>请任何人都可以解决我的问题。帮助将是可观的。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您需要进行以下更改。</p>

<pre><code>AFHTTPSessionManager *manager = ;
[manager GET:@&#34;YourURL&#34; parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
    NSLog(@&#34;JSON: %@&#34;, responseObject);

    NSArray *ResponseArray = (NSArray *)responseObject;
    if (ResponseArray.count &gt;0)
    {
      _spclarr = ;
      NSLog(@&#34;special_array : %@&#34;,_spclarr);

      NSUserDefaults *prefs = ;

      // saving Array to NSUserDefaults
      ;
      ;
      ;

    }
} failure:^(NSURLSessionTask *operation, NSError *error) {
    NSLog(@&#34;Error: %@&#34;, error);
}];
</code></pre>

<p>详细 ViewController </p>

<pre><code>-(void)viewDidLoad
{
    NSUserDefaults *prefs = ;
    //directly reading the array
    menuItems = ;

}
</code></pre>

<p>你的 cellForRowAtIndexPath 应该是这样的</p>

<pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell *cell=;
    NSUserDefaults *prefs = ;
    NSArray *menuItems = ;
    NSDictionary *content = ;

    valueForKey:@&#34;qualification&#34;]];
    return cell;


}
</code></pre>

<p>当我们得到数组格式的响应时,为什么要将其存储在 <code>NSUserDefaults</code> 中作为 NSString ?要摆脱它,您需要直接在 <code>NSUserDefaults</code> 中存储一个数组并直接使用该数组。 </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在自定义 UITableViewCell 中的 Dictionary 中显示数据?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/41257328/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/41257328/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在自定义 UITableViewCell 中的 Dictionary 中显示数据?