How to store CGRect values in NSMutableArray?

后端 未结 4 999
野性不改
野性不改 2021-01-30 01:20

How would I store CGRect objects in a NSMutableArray, and then later retrieve them?

4条回答
  •  心在旅途
    2021-01-30 01:50

    Store string in array.and then get back string and convert that in CGRect back as per the need.
    CGRect rect = CGRectMake( 5, 5, 40, 30 );
    NSString* rectAsString = NSStringFromCGRect( rect );
    NSMutableArray* array = [NSMutableArray mutableArray];
    [array addObject:rectAsString];
    
    For converting string in CGRect back use:-
    CGRect rect9 = CGRectFromString(rectAsString);
    

提交回复
热议问题