Multiple encounters with similar problems are currently only found in the cause, in this record. When you find the solution, add it again.
Problem Description:
Declare Class A, Class B, main class M.
Declare an array of variables in Class A testarray;
@property (nonatomic, strong) Nsarray *testarray;
Instantiate Class A in the main class M, and add a view;
a *a = [[A alloc] Initwithframe:cgrectmake (0,0,20,20)];
[Self addsubview:a];
In class B, an instance of a gets an array of variables Testarray, and assigns values to the arrays;
a *a = [[a alloc] init];
A.testarray = @[@ "M", @ "n", @ "Q"];
The result is that the call array Testarray,testarray in Class A is empty and the assignment fails.
Reason:
The array testarray is called by different instances of Class A, and the allocated memory is different, so the array Testarray is assigned in Class B, and the array Testarray called in Class A is not the same number. Assignment failed.
Current Solution ideas:
1, to a type of single-case, to ensure that the project has only one instance of A; (if there are multiple singleton classes in the project, are there any drawbacks?) )
2. declare static array Testarray; (Test unsuccessful)
Variable assignment for iOS instance class failed