English 中文(简体)
EXC_BAD_ACCESS 安保部
原标题:EXC_BAD_ACCESS when doing operation on NSMutableArray

目前,我试图与一位网络服务器连接,并从中抽出一张桌子。 我已将表格列入一个名为“数据表”的NSMutable阵列(全球)。 然而,当我试图预示任何类型的行动时(图例:计数),它将给我一个EXC_BAD_ACCESS。 BTW I m使用ARC的X代码4.2,因此不是记忆管理问题。 任何建议?

- (void)viewDidLoad
页: 1

    NSURL *url = [NSURL URLWithString: @"`url.com`"];
    NSData *jsonData =[NSData dataWithContentsOfURL:url];

    if(jsonData)

    页: 1
        xmlParser = [[NSXMLParser alloc] initWithData: jsonData];
        [xmlParser setDelegate: self];
        [xmlParser parse];
    iii
    NSLog(@"This is Number of elements: %@",[DataSet count]); ///<----EXC_BAD_ACCESS

 ..... //// default stuff//.....
    iii



- (撤销)parser:NSXMLParser *)parser doEndElement:NSString *)elementName namespaceURI:NSString *
页: 1


    if ([elementName isEqualToString:@"string"])
    页: 1

        /// puts the data into Array luckyNumbers
        NSError *error;
        SBJsonParser *json = [[SBJsonParser new] init];
        DataSet = [[NSMutableArray alloc] init];
        DataSet = [json objectWithString:soapResults error:&error];

      ///  NSLog(@"%@",DataSet); /// this works

    iii
iii

I m not sure if I m suppose to but, I read that I should use Diagnostics, so I turned on NSZombie objects, Malloc guard, and Malloc Stack. They said I should type this into the gdb console info malloc-history (memorylocation)

However I don t know where to get the memory location of the problem. I would appreciate any help.

我无法做到这一点,因此,我尝试使用NSDictionary而不是NSArray,令人惊讶地工作! 这里,我更新了有关任何人的法典。

  • (void)viewDidLoad

页: 1

NSURL *url = [NSURL URLWithString: @"url.com"];
NSData *jsonData =[NSData dataWithContentsOfURL:url];
DataSet = [[NSDictionary alloc] init];

if(jsonData) 页: 1

    xmlParser = [[NSXMLParser alloc] initWithData: jsonData];
    [xmlParser setDelegate: self];
    [xmlParser setShouldResolveExternalEntities:YES];
    [xmlParser parse];
iii
NSLog(@"%@",DataSet.allKeys);

///// default stuff /// iii iii

- (撤销)parser:NSXMLParser *)parser doEndElement:NSString *)elementName namespaceURI:NSString *

页: 1

if ([elementName isEqualToString:@"string"])
页: 1


    //NSLog(@"%@",DataSet);
    DataSet = [soapResults JSONValue];
    NSLog(@"%@",DataSet);

iii

iii

问题回答

(1) 在<条码>上,

DataSet = [[NSMutableArray alloc] init];

2) 在<代码>-(避免)parser:NSXMLParser * parser doEndElement:NSString *)elementName namespaceURI:String * 称, 姓名:

if ([elementName isEqualToString:@"string"])
{
    NSError *error;
    SBJsonParser *json = [[SBJsonParser new] init];
    [DataSet addObject:[json objectWithString:soapResults error:&error]];
    [json release];
}

3) 在<代码>DataSet后面 所有平级物体都将储存





相关问题
WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Convert a 2D array index into a 1D index

I have two arrays for a chess variant I am coding in java...I have a console version so far which represents the board as a 1D array (size is 32) but I am working on making a GUI for it and I want it ...

Convert an array of integers for use in a SQL "IN" clause

Surely there is a framework method that given an array of integers, strings etc converts them into a list that can be used in a SQL "IN" clause? e.g. int[] values = {1,2,3}; would go to "(1,2,3)"

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

C++ Array Sort Me

Stuck on an array sorter. Have to sort numbers from largest to smallest. I m trying two loops (one nested in the other). Here s the code: int counter=0; // inner counter int counter2=0; // outer ...

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

Best practice of big javascript objects

sry for this imprecise topic name. I am querying a dataset a lot of times so using ajax request would end up in tons of http requests. For this reason I decided to use the json encode method to ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

热门标签