开发者

Problem to return object from method objective c

i'm trying to return a Person object that is loaded from the database but the application stops and i get no error message开发者_开发百科 i only get Thread 1: Stopped at breakpoint 3 this is my class:

+ (Person *)searchPersonByName:(NSString *)personName
{
    // Set up sqlite statement
    sqlite3_stmt *db_stmt = nil;

    NSString *sqlQuery = [NSString stringWithFormat:@"SELECT name, id FROM person WHERE name LIKE '%%%@%%'",personName];

    //Convert the sqlQuery string to char
    const char *sqlQueryConverted =[sqlQuery UTF8String]; 

    int prepareSqlQuery = sqlite3_prepare_v2( [[DatabaseManager sharedDatabaseManager] getDb], sqlQueryConverted, -1, &dbStatement, NULL);

    Person *person = [Person alloc];
    //Run the query
    while ( sqlite3_step(db_stmt) == SQLITE_ROW ) 
    {    
        const char *name = (const char *)sqlite3_column_text(db_stmt, 0);
        int personId = sqlite3_column_int(db_stmt, 1);

        //Convert the returnedElement char to string
        NSString *nameString = [[[NSString alloc] initWithUTF8String:name] autorelease];

        [person initWithName:nameString _id:personId];
    }
        return person;
}

I get the error (the program stops) in this line: [person initWithName:nameString _id:personId]; and there's no stack trace.

I guess i don't fully understand how objective c works. I started developing in this language for a couple of weeks ago.

Thanks in advance.


A breakpoint is a marker in the code that you set to stop execution so you can step through the code line by line to see what is happening. This is not an error.... just remove the breakpoint (indicated by a little blue marker on the left of the line... drag it to the right until it disappears).


You have your breakpoints turned on

Problem to return object from method objective c

Turn it off by clicking on it.

Problem to return object from method objective c

It should look like this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜