NSArray
並べ替えが機能しない理由がわかりDBMetadata (NSObject)
ませんでした。これが私のコードです。なにが問題ですか?追加するカテゴリを追加しようとしましたcompare:
が、機能しません。
- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata {
if (metadata.isDirectory) {
NSLog(@"Folder '%@' contains:", metadata.path);
for (DBMetadata *file in metadata.contents) {
NSLog(@"\t%@ is directory? %d", file.filename, file.isDirectory);
if (file.isDirectory) {
[self.availableBackups addObject:file];
DLog(@"llastModifiedDate %@", file.lastModifiedDate);
}
}
}
// NSLog(@"before sorting: %@", self.availableBackups); //lastModifiedDate //filename
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"lastModifiedDate" ascending:YES selector:@selector(compare:)];
[self.availableBackups sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]];
// NSLog(@"after sorting: %@", self.availableBackups);
}
self.availableBackups
はNSMutableArray
@property (nonatomic, retain) NSMutableArray *availableBackups;
ドロップボックス- DBMetadata.h
NSLog
obj のアドレスを出力するだけのコメントが付けられていYES
ます。NO
ascending:
出力
2013-01-31 17:20:12.423 Dropbox[7366:c07] before sorting: (
"<DBMetadata: 0x6bbf010>",
"<DBMetadata: 0x6bbfb50>",
"<DBMetadata: 0x6bc1660>",
"<DBMetadata: 0x6bc17b0>",
"<DBMetadata: 0x6bc14f0>",
"<DBMetadata: 0x6bc0dd0>",
"<DBMetadata: 0x6bc1de0>"
)
2013-01-31 17:20:12.424 Dropbox[7366:c07] after sorting: (
"<DBMetadata: 0x6bbf010>",
"<DBMetadata: 0x6bbfb50>",
"<DBMetadata: 0x6bc1660>",
"<DBMetadata: 0x6bc17b0>",
"<DBMetadata: 0x6bc14f0>",
"<DBMetadata: 0x6bc0dd0>",
"<DBMetadata: 0x6bc1de0>"
)
昇順でNO
Last Modified file at 0: 2013-01-30 08:00:22 +0000
Last Modified file at 1: 2013-01-30 08:02:54 +0000
Last Modified file at 2: 2013-01-31 09:08:26 +0000
Last Modified file at 3: 2013-01-31 09:14:55 +0000
Last Modified file at 4: 2013-01-31 09:14:08 +0000
Last Modified file at 5: 2013-01-31 09:16:43 +0000
Last Modified file at 6: 2013-01-31 10:36:13 +0000