Incompatible pointer types designating "nsmutablearray" from "nsarray" in Objective-C

users = [users arrayByAddingObjectsFromArray:arrayvalue]; 

users is NSMutableArray , and arrayvalue is also NSMutableArray , I add the value of arrayvalue to the users array, but I get the warning "incompatible pointer types assigned by NSMutableArray from NSArray ".

I searched, but could not find a solution for this.

+4
source share
1 answer

Although arrayvalue is an NSMutableArray, the return value of arrayByAddingObjectsFromArray: is equal to NSArray , and therefore you get this warning.

You must call [users addObjectsFromArray:arrayvalue]; which modifies the array returns NSMutableArray .

See the NSMutableArray link for more NSMutableArray .

+9
source

Source: https://habr.com/ru/post/1388895/


All Articles