我声明了在firstviewcontroller阵列等添加对象,具有自定义委托功能给错误
@interface ClassesList : UIViewController
{
NSMutableArray *className;
}
@property (retain,nonatomic) NSMutableArray *className;
并限定委托方法在下一视图控制器对象添加到数组的NSMutableArray
@protocol Createclass <NSObject>
-(void)addnewObject:(NSString*)string;;
@end
并发送字符串与文本文件的字符串
[self.delegate addnewClass:_className.text];
while calling this met OD在firstviewcontroller它显示错误
NSInvalidArgumentException', reason: '-[__NSArrayI addObject:]: unrecognized selector sent to instance
这里是我的编辑
-(void)addnewClass:(NSString *)string
{
[className addObject:string];
[self.table reloadData];
}
我越来越从plist文件存储类
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"classesArray.plist"];
NSDictionary *StudentDict=[[NSDictionary alloc]initWithContentsOfFile:path];
NSArray *See = StudentDict[@"alldata"];
className = [[NSMutableArray alloc]init];
className= [See valueForKey:@"class_name"];
您能否在您的firstViewController中发布 - (void)addnewObject:(NSString *)字符串的代码 – AntonijoDev
Adn yout协议方法被称为addnewObject而不是addnewClass,所以它应该是[self.delegate addnewObject:_className。文本]; – AntonijoDev
@AntonijoDev对不起addnewObject只是为发布问题而改变 – user3595019