Niharika
Niharika

Reputation: 1198

__NSCFDictionary stringByDeletingPathExtension crash

I am displaying a data in a UITableView taken from a Web Service . While trying to add this data in UITableView I am getting some weird crash

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary stringByDeletingPathExtension]: unrecognized selector sent to instance 0x7f9bc68530e0'

Can anyone tell me what kind of error is this. this is my response

<__NSCFArray 0x7fd2846dec80>(
{
    DISTANCE = "2677.2557594500167";
    POPULARITY = 0;
    PRICE = "";
    "bar_id" = 1;
    "event_id" = "";
    "event_name" = "";
    "is_following" = 0;
    "participant_count" = 0;
    "venue_address" = “abc”;
    "venue_image" = "http://dsfdsf.com/uploads/venue_icon/original/8PHHBUbASoZZXdQNOyqL1jKAmd08rowg.jpg";
    "venue_name" = "CLUB";
},
{
    DISTANCE = "2677.2557594500167";
    POPULARITY = 0;
    PRICE = "";
    "bar_id" = 2;
    "event_id" = "";
    "event_name" = "";
    "is_following" = 0;
    "participant_count" = 0;
    "venue_address" = “def”;
    "venue_image" = "http://dsfdsf.com/uploads/venue_icon/original/8PHHBUbASoZZXdQNOyqL1jKAmd08rowg.jpg;
    "venue_name" = “Club";
}
)

This is the way i am adding data to UITableViewCell

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell.lbl_eventName.text = [[arrayEventData valueForKey:@"venue_name"]objectAtIndex:indexPath.row];
}

Upvotes: 3

Views: 190

Answers (5)

Dishant Rajput
Dishant Rajput

Reputation: 1357

try this

NSDictionary *yourDict =[yourArray objectAtIndex:indexPath.row];
cell.lbl_eventName.text = [yourDict valueForKey:@"venue_name"];

Upvotes: 0

Krutarth Patel
Krutarth Patel

Reputation: 3455

You can try this solution

 NSDictionary*dict       = [Self.arrayEventData objectAtIndex:indexPath.row];
 cell.lbl_eventName.text = [dict valueForKey:@"venue_name"];

Upvotes: 1

Ankur
Ankur

Reputation: 84

You can also handle it with few validation for null or nil value.

NSString *strVanue = [[arrayEventData objectAtIndex:indexPath.row] valueForKey:@"venue_name"];

if(strVanue != nil || strVanue != (id)[NSNull null]){

   cell.lbl_eventName.text = strVanue;
}

Upvotes: 0

Laxman Sahni
Laxman Sahni

Reputation: 612

You're trying to access value of dict in array. First a Dictionary object from

[Self.arrayEventData objectAtIndex:indexPath.row] and call

[dict valueForKey:@"venue_name"]

Upvotes: 1

sohil
sohil

Reputation: 848

try this :

cell.lbl_eventName.text = [[arrayEventData objectAtIndex:indexPath.row] valueForKey:@"venue_name"];

Upvotes: 3

Related Questions