- #import <Foundation/Foundation.h>
- @interface PlayList : NSObject
- @property (nonatomic,copy) NSMutableArray *songArray;
- @end
- @implementation PlayList
- @end
- int main(int argc, const char * argv[]) {
- @autoreleasepool {
-
- PlayList *pl = [PlayList new];
-
- NSMutableArray *arr1 = [NSMutableArray array];
- pl.songArray = arr1;
-
- [arr1 addObject:@"ab"];
-
- NSLog(@"%@",arr1);
- }
- return 0;
- }
复制代码
你的问题出在第十行,arr1还没有被创建出来,你那个写法是错误的,应该先创建arr1对象,然后在把arr1赋值给 pl.songArray,这样就可以了 |