Add CGRect to NSMutableArray

Problem: you want to add CGRect to NSMutableArray but editor marks it as an error.

Solution: error is shown because NSMutableArray is an array of objects. CGRect, however, is a structure.

What you need to do is to pack the CGRect into the NSValue object and then add newly created NSValue object into the NSMutableArray array. Like so:

[mutableArray addObject:[NSValue valueWithCGRect:myView.frame]];
[mutableArray addObject:[NSValue valueWithCGRect:myView.frame]];

Komentowanie jest zakończone.