Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange behavior with NSObject Properties
    primarykey
    data
    text
    <p>I have an <code>NSObject</code> that I am using to store/hold properties of an object, one of them being a "Name" property cast as an <code>NSString</code>. I am also pulling data from a SQLite DB for said object using the following:</p> <pre><code>- (void) getDataToDisplay:(NSString *)dbPath { if (sqlite3_open([dbPath UTF8String], &amp;database) == SQLITE_OK) { NSString *queryOnStyle = [NSString stringWithFormat: @"SELECT WineId, Name FROM wine WHERE StyleId = %d", dataManager.styleId]; const char *sql = [queryOnStyle UTF8String]; sqlite3_stmt *selectstmt; if(sqlite3_prepare_v2(database, sql, -1, &amp;selectstmt, NULL) == SQLITE_OK) { while(sqlite3_step(selectstmt) == SQLITE_ROW) { Wine *w = [[Wine alloc] init]; w.wineId = sqlite3_column_int(selectstmt, 0); w.wineName = [NSString stringWithUTF8String: (char *)sqlite3_column_text(selectstmt, 1)]; [dataManager.wines addObject:w]; [w release]; } } } else sqlite3_close(database); //Even though the open call failed, close the database connection to release all the memory. } </code></pre> <p>Wine being my object. If I were to log <code>w.wineName</code> at this point, there is no problem. The problem occurs later when I try to access the properties of the object from within the array, <code>dataManager.wines</code>, in a custom tableView. It suddenly treats my <code>wineName</code> as a <code>UIImageView</code> rather than an <code>NSString</code>...</p> <p>I for the life of me cannot trace anything back to ever being cast as a <code>UIImageView</code> and have no idea why it would be setting just that property as such. Here is the code for my custom tableView:</p> <pre><code>#pragma mark - #pragma mark HorizontalTableViewDelegate methods - (NSInteger)numberOfColumnsForTableView:(HorizontalTableView *)tableView { return [dataManager.wines count]; } - (UIView *)tableView:(HorizontalTableView *)aTableView viewForIndex:(NSInteger)index { UIView *vw = [aTableView dequeueColumnView]; if (!vw) { [[NSBundle mainBundle] loadNibNamed:@"ColumnView" owner:self options:nil]; vw = self.columnView; self.columnView = nil; } // Get the wineId from the array of wineId integers Wine *w = [dataManager.wines objectAtIndex:index]; int tempWineId = w.wineId; NSString *tempWineName = [NSString stringWithFormat:@"%@", w.wineName]; NSLog(@"%@", tempWineName); \\RETURNS TEMPWINENAME AS A UIIMAGEVIEW [w release]; return vw; } - (CGFloat)columnWidthForTableView:(HorizontalTableView *)tableView { //TODO: This value needs to change if changed in IB return 209.0f; } </code></pre> <p>any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload