Grids Crashes on me


#1

I am using the code that came with the sample CreatingCustomCells. I got it to work except that there are fields that makes the grid crashes when scrolled. There is an MD5 Field, and two URL fields. If I remove those fields, the grid works fine. Any ideas? Here is part of my json file:

 {
                   "timestamp": "2011/03/11 11:20:59 GMT+0000",
                  "userName": "SMELKH",
                  "Hostname": "tk421",
                   "MD5Hash": "4ad8e4cfe7f8567f856d775b4afc2cdecbee",
                   "fileName": "pudding.zip",
                  "fileSize": "1102434",
                   "MaliciousURL": "file.filenolja.com",
                   "MaliciousIP": "218.38.12.97",
                  "country": "Korea",
                  "numDetects": "26",
                  "numEvents": "45"

                  },
 
Here is the code for the dataSource:
 
       LogFile* detectionRec = [[LogFile alloc] init];
        detectionRec.timeStampe = [jsonDetection objectForKey:@"timestamp"];
        detectionRec.userName = [jsonDetection objectForKey:@"userName"];
        detectionRec.Hostname = [jsonDetection objectForKey:@"Hostname"];
        detectionRec.MD5Hash =      (NSString *)[jsonDetection objectForKey:@"MD5Hash"];
        detectionRec.fileName = [jsonDetection objectForKey:@"fileName"];
        detectionRec.fileSize = [self numberFromDictionary:jsonDetection key:@"fileSize"];
        detectionRec.maliciousURL = (NSURL *) [jsonDetection objectForKey:@"MaliciousURL"];
        detectionRec.MaliciousIP    = (NSURL *) [jsonDetection objectForKey:@"MaliciousIP"];
        detectionRec.country    = (NSString *)[jsonDetection objectForKey:@"country"];
        detectionRec.numDetects = [self numberFromDictionary:jsonDetection key:@"numDetects"];
        detectionRec.numEvents  = [self numberFromDictionary:jsonDetection key:@"numEvents"];
 
        [dectionRecords addObject:detectionRec];
 
Here is part of the code create one of the columns. What Am I doing wrong? Thank you

#2

Sorry, Update: Code to create one of the columns:

   // add Malicious URL column
    SDataGridColumn* MaliciousURLCol = [[SDataGridColumn alloc] initWithTitle:@"Malicious URL" forProperty:@"MaliciousURL"];
    MaliciousURLCol.width = @200;
     MaliciousURLCol.sortMode = SDataGridColumnSortModeTriState;

    [_shinobiDataGrid addColumn:MaliciousURLCol];

#3

Greetings Program!

If the type is NSURL for those properties, when you set the grid column value make sure you’re casting it as string.

Wg


#4

I’ve tried that. It still crashes. Any other ideas?

Thanks in Advance!!


#5

Can you show me the code where you’re setting all the columns?

Wg


#6

Sure, Thanks so much for your help!

-(void )createGrid:(NSString *)withName andWithGridView:(UIView *)gridSubView
 
{
    
     // create a grid that occupies the entire view
     _shinobiDataGrid = [[ShinobiDataGridalloc] initWithFrame:CGRectInset(self.view.bounds, 5, 5)];
    UIFont *font = [UIFont fontWithName:@"Helvetica" size:16.0f];
     _shinobiDataGrid.licenseKey = LIC_KEY; // TODO: add your trial licence key here!
 
     // add to the view
    [gridSubView addSubview:_shinobiDataGrid];
    
     // create an alternating row style
    
     //Create the Alternating Row style
    UIEdgeInsets padding = UIEdgeInsetsMake(5, 5, 5, 5);
     SDataGridCellStyle* alternatingRowStyle = [[SDataGridCellStylealloc] init];
alternatingRowStyle.font = font;
alternatingRowStyle.contentInset = padding;
    alternatingRowStyle.backgroundColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
    
     // Create the header style.
SDataGridCellStyle* headerStyle = [[SDataGridCellStylealloc] init];
    headerStyle.font = font;
    headerStyle.contentInset = padding;
headerStyle.backgroundColor = [UIColor colorWithWhite:0.6f alpha:1.0f];
headerStyle.textColor = [UIColor whiteColor];
    
     //Create Row Style
     SDataGridTheme *verticalLinesTheme =[SDataGridiOS7Themenew];
    [_shinobiDataGrid applyTheme:verticalLinesTheme];
     // Set the row heights.
 _shinobiDataGrid.defaultHeaderRowHeight = @30;
_shinobiDataGrid.defaultRowHeight = @30;
// Set the cell styles.
     _shinobiDataGrid.defaultCellStyleForHeaderRow = headerStyle;
     _shinobiDataGrid.defaultCellStyleForAlternateRows = alternatingRowStyle;
 
// Create the style for the cell.
SDataGridCellStyle* cellStyle;
    
     // add a User Name column
    SDataGridColumn* userNameCol = [[SDataGridColumn alloc] initWithTitle:@"User" forProperty:@"userName"];
    userNameCol.width = @100;
     userNameCol.sortMode = SDataGridColumnSortModeTriState;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentLeft;
userNameCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:userNameCol];
 
     // add a Host Name column
    SDataGridColumn* hostNameCol = [[SDataGridColumn alloc] initWithTitle:@"Host" forProperty:@"Hostname"];
    hostNameCol.width = @80;
     hostNameCol.sortMode = SDataGridColumnSortModeTriState;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentLeft;
hostNameCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:hostNameCol];
    
//    // add Malicious URL column
    SDataGridColumn* MaliciousURLCol = [[SDataGridColumn alloc] initWithTitle:@"Malicious URL"                    forProperty:@"MaliciousURL"];
    MaliciousURLCol.width = @200;
     MaliciousURLCol.sortMode = SDataGridColumnSortModeTriState;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
     cellStyle.textAlignment = NSTextAlignmentLeft;
    MaliciousURLCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:MaliciousURLCol];
    
//    // add Malicious IP column
    SDataGridColumn* MaliciousIPCol = [[SDataGridColumn alloc] initWithTitle:@"Malicious IP" forProperty:@"MaliciousIP"];
    MaliciousIPCol.width = @150;
     MaliciousIPCol.sortMode = SDataGridColumnSortModeTriState;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentLeft;
    MaliciousIPCol.cellStyle = cellStyle;
   [_shinobiDataGrid addColumn:MaliciousIPCol];
    
     // add From Country column
     SDataGridColumn* countryCol = [[SDataGridColumnalloc] initWithTitle:@"Country"forProperty:@"country"];
    countryCol.width = @100;
     countryCol.sortMode = SDataGridColumnSortModeTriState;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentLeft;
countryCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:countryCol];
    
     // add a Md5 Hash column
     SDataGridColumn* MD5HashCol = [[SDataGridColumnalloc] initWithTitle:@"MD5 Hash"forProperty:@"MD5Hash"];
    MD5HashCol.width = @220;
     MD5HashCol.sortMode = SDataGridColumnSortModeNone;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentLeft;
    MD5HashCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:MD5HashCol];
    
     // add Suspected file column
    SDataGridColumn* fileNameCol = [[SDataGridColumn alloc] initWithTitle:@"File Name" forProperty:@"fileName"];
    fileNameCol.width = @150;
     fileNameCol.sortMode = SDataGridColumnSortModeNone;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentLeft;
fileNameCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:fileNameCol];
//
     // add suspected file Size column
    SDataGridColumn* fileSizeCol = [[SDataGridColumn alloc] initWithTitle:@"File Size" forProperty:@"fileSize"];
    fileSizeCol.width = @100;
     fileSizeCol.sortMode = SDataGridColumnSortModeNone;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentLeft;
fileSizeCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:fileSizeCol];
    
     // add Number of Detections column
    SDataGridColumn* numDetectsCol = [[SDataGridColumn alloc] initWithTitle:@"#Detects" forProperty:@"numDetects"];
    numDetectsCol.width = @110;
     numDetectsCol.sortMode = SDataGridColumnSortModeTriState;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentCenter;
numDetectsCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:numDetectsCol];
 
     // add Number of Events column
    SDataGridColumn* numEventsCol = [[SDataGridColumn alloc] initWithTitle:@"#Events" forProperty:@"numEvents"];
    numEventsCol.width = @110;
     numEventsCol.sortMode = SDataGridColumnSortModeTriState;
    cellStyle = [[SDataGridCellStyle alloc] init];
    cellStyle.font = font;
    cellStyle.contentInset = padding;
 cellStyle.textAlignment = NSTextAlignmentCenter;
numEventsCol.cellStyle = cellStyle;
    [_shinobiDataGrid addColumn:numEventsCol];
    
     // create some data to populate the grid
     _data = [StockPriceDataSourcegetStockPrices];
    
     // create the helper
     _datasourceHelper = [[SDataGridDataSourceHelperalloc] initWithDataGrid:_shinobiDataGrid];
     _datasourceHelper.delegate = self;
    
     // supply the data to the helper
     _datasourceHelper.data = _data;

}

#7

Hi, any luck with this? I really need your help before I forkout $,1000 for the bundle. I am a small developer and I want to make sure this is going to work for me. Please let me know if you need anymore information. Thank you.


#8

Your property name is lowercase “m” and your setting it for an uppercase “M”:

SDataGridColumn* MaliciousURLCol = [[SDataGridColumn alloc] initWithTitle:@"Malicious URL" forProperty:@"MaliciousURL"];

detectionRec.maliciousURL = (NSURL *) [jsonDetection objectForKey:@"MaliciousURL"];

Wg


#9

Resovled the Issue. the fields that were causing problems were defined as @property (nonatomic, assign) where they should’ve been (nonatomic, strong). Those fields contents were converted to HEX when the datasource was being accessed during scrolling.

-Sam