Reputation: 11
I am a beginner in iOS, can some one help me:
I am getting warning: string is not a string literal (potentially insecure)
for below code
-( void )gettingEntitySchemaForGivenKayValueFromDataBase:( RequestType )requestType ParamDict:( NSDictionary * )parameterDict
{
PersistenceFromDataBase *persistanceDataObj=[ PersistenceFromDataBase sharedInstance ];
//[ NSJSONSerialization dataWithJSONObject:[ persistanceDataObj getEntitySchemaForGinvenEntityIs:parameterDict ] options:NSJSONWritingPrettyPrinted error:nil ];
NSDictionary *dataDict= [ persistanceDataObj getEntitySchemaForGinvenEntityIs:parameterDict ];
id datatoserialize=[ dataDict objectForKey:VIEWS_KEY ];
NSLog([ NSJSONSerialization dataWithJSONObject:datatoserialize options:NSJSONWritingPrettyPrinted error:nil ])
;
NSLog(@" entitySchemaForEntityId:%@",dataDict );
// [[ NSNotificationQueue defaultQueue ] enqueueNotification:[ NSNotification notificationWithName:ENTITYSCHEMANOTIFICATION object:nil userInfo:@{ USER_INFO:dataDict }] postingStyle:NSPostWhenIdle ];
// sent view data to view controller
}
Upvotes: 1
Views: 199
Reputation: 2457
Replace your
NSLog([ NSJSONSerialization dataWithJSONObject:datatoserialize options:NSJSONWritingPrettyPrinted error:nil ])
;
with the following one
NSLog(@"%@", [NSJSONSerialization dataWithJSONObject:datatoserialize options:NSJSONWritingPrettyPrinted error:nil]);
Upvotes: 0
Reputation: 2360
For your code NSLog([ NSJSONSerialization dataWithJSONObject:datatoserialize options:NSJSONWritingPrettyPrinted error:nil ])
, NSLog
actually prints a string and needs a string format as input.
The function dataWithJSONObject:options:error:
returns NSData
and Not NSString
, hence the warning.
You may try this instead NSLog(@"%@",[ NSJSONSerialization dataWithJSONObject:datatoserialize options:NSJSONWritingPrettyPrinted error:nil]);
Upvotes: 0
Reputation: 5536
Your NSLog
is missing a format specifier. Use this instead:
NSLog(@"%@",[NSJSONSerialization dataWithJSONObject:datatoserialize options:NSJSONWritingPrettyPrinted error:nil])
;
Upvotes: 1