我有一个对象,如下
#import <Foundation/Foundation.h>
@interface CountriesDAO : NSObject
@property (nonatomic, retain) NSString * countryname;
@end
#import "CountriesDAO.h"
@implementation CountriesDAO
@synthesize countryname;
@end
我已将其保存在 appDelegate 中的数组中。
@property (nonatomic, retain) NSArray *countriesArray;
@synthesize countriesArray;
在另一个控制器中,我像
NSArray *countriesArray = appDelegate.countriesArray; It works fine and I get array.
当我尝试以这种方式对其进行排序时。
NSArray *countriesArray1 = appDelegate.countriesArray;
NSSortDescriptor *valueDescriptor = [[NSSortDescriptor alloc] initWithKey:@"countryname" ascending:YES];
NSArray * descriptors = [NSArray arrayWithObject:valueDescriptor];
countriesArray = [countriesArray1 sortedArrayUsingDescriptors:descriptors];
我收到错误
[__NSCFType count]: unrecognized selector sent to instance 0xa83b4d0
2013-11-01 13:21:08.882 ECP[13597:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType count]: unrecognized selector sent to instance 0xa83b4d0'
这里国家数组定义为
@property (nonatomic, retain) NSArray *countriesArray;