简体   繁体   中英

Why we take lastObject for Standard Directories in iOS?

I was reading some documentation about standard directories in iOS. I checked Here , and found this method.

- (NSURL *)applicationDocumentsDirectory {
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

One thing i didn't get why it's taking lastObject from NSArray and didn't found any explanation.

If you have tried to debug and find out what is in that array returned by NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) then you might not need any explanation. This is basically returning address of your documents folder and contains only one object. By using lastObject or firstObject doesn't make any difference, you can use firstObject to check it yourself and might help you in understanding too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM