if we have a custom data object 'Question *obj' and initial a NSDictionary with obj
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:obj.value1], @"QuestionNo",
obj.value2, @"QuestionKind",
obj.value3, @"Question",
nil];
The above 'dict' has 3 key/value pairs in most time.
But, dict may lost the content(less than 3 pairs) if the 'Question *obj' has nil value.
Because [NSDictionary dictionaryWithObjectsAndKeys:] stops to add objects when it finds a nil value.
沒有留言:
張貼留言