Add struct, use Nsvlue class
|
typedefstruct{ Nsuintegerline; Nsuintegerrow; } tilelocation; Convert to Nsvalue Nsvalue*value = [Nsvaluevaluewithbytes:&tilelocobjctype: @encode (tilelocation)]; Convert back to struct Tilelocation Loc; [valuegetvalue:&loc]; CGRect rect1 = CGRectMake (0, 0, image1.size.width, image1.size.height); CGRect rect2 = CGRectMake (IMAGE1.SIZE.WIDTH/4, 0, IMAGE1.SIZE.WIDTH/2, IMAGE1.SIZE.HEIGHT/2); Nsvalue *rectvalue1 = nil; Nsvalue *rectvalue2 = nil; rectValue1 = [Nsvalue valuewithbytes:&rect1 objctype: @encode (CGRect)]; RectValue2 = [Nsvalue valuewithbytes:&rect2 objctype: @encode (CGRect)]; Nsarray *rectarr = [Nsarray arraywithobjects:rectvalue1,rectvalue2, Nil]; CGRect Tmprect; [[Rects objectatindex:i] getvalue:&tmprect]; |
This article is from the "zhuoking" blog, make sure to keep this source http://9951038.blog.51cto.com/9941038/1772581
IOS Nsarray, struct