#import < QuartzCore/QuartzCore.h>
CALayer *imageLayer = myImageView.layer;
CGFloat height = imageLayer.frame.size.height;
CGFloat width = imageLayer.frame.size.width;
CGFloat roundRadius = height > width ? width / 2 : height / 2;
[imageLayer setCornerRadius:roundRadius];
[imageLayer setBorderWidth:1];
[imageLayer setMasksToBounds:YES];
[imageLayer setBorderColor:[[UIColor redColor] CGColor]];
[Objective-C]NSDictionary dictionaryWithObjectsAndKeys: lost content
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.
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.
訂閱:
文章 (Atom)