madcoderz
madcoderz

Reputation: 4431

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.

Upvotes: 0

Views: 202

Answers (2)

Simon Lee
Simon Lee

Reputation: 22334

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).

Upvotes: 2

Robin
Robin

Reputation: 10011

You have your breakpoints turned on

enter image description here

Turn it off by clicking on it.

enter image description here

It should look like this

Upvotes: 1

Related Questions