I am making a framework and I have this code (conditions
is an NSDictionary):
for (NSString *key in conditions) {
id value = [[conditions valueForKey:key] retain];
// Check if number or string
if ([value class] == [NSString class]) {
conditionsString = [NSString stringWithFormat:@"%@='%@' ", key, value];
} else {
conditionsString = [NSString stringWithFormat:@"%@=%@ ", key, value];
}
}
If the value
is an NSString, quotes should be added, otherwise codes should not be added. However, if not an NSString, I don't know the datatype of value
, as it could be NSNumber, NSInteger, int, float, double, etc... I can't just use %@
or %d
but I'm sure someone on SO knows how to do this? Thanks.