Created
July 10, 2018 15:34
-
-
Save hamada147/69fb9e778866c9e4221ede2014d98339 to your computer and use it in GitHub Desktop.
Error in this code happen inside Infaragistics Framework -[IGGridViewColumnDefinition resolveValueForObject:inDataSource:] + 112.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"replyCode": "0", | |
"replyMessage": "Succcess", | |
"responseDetails": [ | |
{ | |
"unrealizedGainLossPercentage": "15.23", | |
"marketValueProductCurrency": "131223845.03", | |
"marketValueSAR": "131223845.03", | |
"unrealizedGainLoss": "3170616.28", | |
"totalCost": "128053228.75", | |
"marketName": "Saudi Market", | |
"allocationPercentage": "40.96", | |
"currency": "SAR" | |
}, | |
{ | |
"unrealizedGainLossPercentage": "6.23", | |
"marketValueProductCurrency": "27888382.02", | |
"marketValueSAR": "104581301.86", | |
"unrealizedGainLoss": "1288382.02", | |
"totalCost": "26600000", | |
"marketName": "Dubai Financial Market", | |
"allocationPercentage": "32.66", | |
"currency": "SAR" | |
}, | |
{ | |
"unrealizedGainLossPercentage": "35.01", | |
"marketValueProductCurrency": "76165664.43", | |
"marketValueSAR": "76165664.43", | |
"unrealizedGainLoss": "1165664.43", | |
"totalCost": "75000000", | |
"marketName": "Kuwait", | |
"allocationPercentage": "23.78", | |
"currency": "SAR" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"replyCode": "0", | |
"replyMessage": "Succcess", | |
"responseDetails": [ | |
{ | |
"order": "1", | |
"fieldType": "TEXT", | |
"columnName": "Market Name", | |
"fieldName": "marketName" | |
}, | |
{ | |
"order": "2", | |
"fieldType": "TEXT", | |
"columnName": "Currency", | |
"fieldName": "currency" | |
}, | |
{ | |
"order": "3", | |
"fieldType": "PRICE", | |
"columnName": "Total Cost", | |
"fieldName": "totalCost" | |
}, | |
{ | |
"order": "4", | |
"fieldType": "PRICE", | |
"columnName": "Market Value Product Currency", | |
"fieldName": "marketValueProductCurrency" | |
}, | |
{ | |
"order": "5", | |
"fieldType": "PRICE", | |
"columnName": "Market Value SAR", | |
"fieldName": "marketValueSAR" | |
}, | |
{ | |
"order": "6", | |
"fieldType": "PRICE", | |
"columnName": "Unrealized Gain/Loss Value", | |
"fieldName": "unrealizedGainLoss" | |
}, | |
{ | |
"order": "7", | |
"fieldType": "PRICE", | |
"columnName": "Unrealized Gain/Loss Value %", | |
"fieldName": "unrealizedGainLossPercentage" | |
}, | |
{ | |
"order": "8", | |
"fieldType": "PRICE", | |
"columnName": "Allocation %", | |
"fieldName": "allocationPercentage" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MainWidgetViewController | |
- (NSArray *)getArrayOfRecrodsFrom: (NSArray *)response { | |
NSMutableArray * rows = [[NSMutableArray alloc] init]; | |
if ([response count] != 0) { | |
// 1. get all NSDictionary keys | |
NSDictionary * temp = response[0]; | |
NSArray * keys = [temp allKeys]; | |
if (!NSClassFromString(self.ServiceName)) { | |
// 2. create a class | |
self.ModelClass = objc_allocateClassPair([NSObject class], [self.ServiceName UTF8String], 0); | |
// 3. all class variables with the same name as key retrieved from NSDictionary | |
for (NSString * key in keys) { | |
const char * name = [key UTF8String]; | |
class_addIvar(self.ModelClass, name, sizeof(id), rint(log2(sizeof(id))), @encode(id)); | |
objc_property_attribute_t type = {"T", "@\"NSString\""}; // type | |
objc_property_attribute_t ownership1 = {"&", "" }; // stong | |
objc_property_attribute_t ownership2 = {"N", "" }; // | |
objc_property_attribute_t backingivar = {"V", name}; // name | |
objc_property_attribute_t attrs[] = {type, ownership1, ownership2, backingivar}; | |
unsigned int attrCount = sizeof(attrs)/sizeof(attrs[0]); | |
class_addProperty(self.ModelClass, name, attrs, attrCount); | |
} | |
// 4. register a class to be used | |
@try { | |
objc_registerClassPair(self.ModelClass); | |
} @catch (NSException * e) { | |
NSLog(@"Exception in class registeration: %@", e); | |
} | |
} else { | |
self.ModelClass = NSClassFromString(self.ServiceName); | |
} | |
for (NSDictionary * curr in response) { | |
// create object | |
id MC = [[self.ModelClass alloc] init]; | |
for (int i = 0, size = (int)[keys count]; i < size; i++) { | |
NSString * newValue = [[NSString alloc] init]; | |
NSString * type = [self getColumnType: keys[i]]; | |
if ([type isEqualToString:@"PRICE"]) { | |
newValue = [NSString stringWithFormat:@"%.02f", [[curr objectForKey: keys[i]] doubleValue]]; | |
} else { | |
newValue = [curr objectForKey: keys[i]]; | |
} | |
// set values for Ivar | |
const char * name = [keys[i] UTF8String]; | |
Ivar CurrVar = class_getInstanceVariable(self.ModelClass, name); | |
object_setIvar(MC, CurrVar, [newValue copy]); | |
} | |
// add object to array | |
[rows addObject:MC]; | |
} | |
} | |
return rows; | |
} | |
- (NSString *)getColumnType:(NSString *)colName { | |
for (TableColumn * col in self.TableColumns) { | |
if ([colName isEqualToString:col.fieldName]) { | |
return col.fieldType; | |
} | |
} | |
return @"TEXT"; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment