Results 1 to 6 of 6

Thread: [RESOLVED] Xcode: Strange errors

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] Xcode: Strange errors

    Hi,

    Is there anyone with xcode that can get my homework exercise working correctly? I can get the number of errors down to 2- 4 however, no matter what I have tried I can't get the project work correctly. If you manage to get the project to run could you please post the code and/or steps to get the project work here.

    Thanks,


    Nightwalker
    Last edited by Nightwalker83; Nov 19th, 2012 at 06:53 PM. Reason: Removed attachment!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Xcode: Strange errors

    Code:
    #import "DatabaseShoppingListAppDelegate.h";
    No semi colon after imports.

    Code:
    #include <sqlite3.h>
    Use #import

    Code:
    NSString *ADD_GROUP_NAMES[] = {@"Groceries", @"Tech"};
    I strongly advise against using C arrays with foundation objects. Use NSArrays instead.

    Code:
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    This was a weird one. Once I copied the definition from the SDK header, it worked. Turns out you had an invisible character between - and ( that threw the compiler of. When adding data source and delegate methods it's best to copy the declarations from the docs or headers.

    Code:
    ...  values (\"%@\", %@, \"%@\", %@, %d, DATETIME('NOW'))", itemNameField.text, priceField.text, [groupPicker selectedRowInComponent: 0]];
    What's with that line? You have 5 format specifier but only three values.

    Once you fix those your project should compile, though it still has issues.

  3. #3

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Xcode: Strange errors

    Since it is a homework exercise I did not write the code myself but retyped it from the pdf we were given in class. Unfortunately, I am interstate until Sunday so I will not be able to check previous versions of the project until I get home.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Xcode: Strange errors

    @ Baja_yu

    I have another strange error that I need help with although when I run the project no errors appear however, no data appears in the table view even though I have created the database, populated it, called the functions initialize the database and to load the data from the database. A friend of mine tried helping me solve the problem as he said that the code looks identical to his but for some reason mine was loading the data from the database then initializing the database rather than the other way around.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Xcode: Strange errors

    The problem is in your 'loadDataFromDb' method. Do some debugging there. Based on the console output it's not entering this IF block

    if(sqlite3_prepare_v2(db, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {


    And a note. Inside movie.h you declared:

    -(id)initWithmovieID:(NSNumber *)newmovieID title:(NSString *)newtitle price:(NSNumber *)newprice;

    but implemented:

    -(id)initWithMovieID:(NSNumber *)newmovieID title:(NSString *)newtitle price:(NSNumber *)newPrice {

    Objective C is case sensitive so those would be considered two different methods.

  6. #6

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Xcode: Strange errors

    Quote Originally Posted by baja_yu View Post
    if(sqlite3_prepare_v2(db, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
    Yeah, but I can't figure out why it is not entering that block! I checked the database and everything was fine with it.

    Edit:

    Comparing the code of the project that is not working I have:

    Code:
    - (void)viewDidLoad {
        [super viewDidLoad];
    	[self loadDataFromDb];
        [self.tableView reloadData];    // Uncomment the following line to preserve selection between presentations.
        //self.clearsSelectionOnViewWillAppear = NO;
     
        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    }
    in the project that is not working, compare that to a project that is working:

    Code:
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    	[self loadDataFromDb];
    	[self.tableView reloadData];
    }
    note: In the project that is working the bold lines are in the "- (void)viewWillAppear:(BOOL)animated" function. If I remember correctly, the database needed to be remade for some reason as the computers at school stuffing up so I gather that even if I had the above code in the correct spot the project wouldn't have worked anyway because of issues with the compiler.
    Last edited by Nightwalker83; Nov 26th, 2012 at 10:08 PM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width