当前位置: 首页 > 工具软件 > deprecated > 使用案例 >

Deprecated

严朝明
2023-12-01

有时候我们在网上遇到的一些代码运行时,可能会出现这样的warning:"****"is deprecated .出现这个警告的原因是苹果公司对这些函数进行升级和改进,或者说对那些函数进行功能优化。我们需要去开发文档中查询我们用到的函数,将出现这种警告的函数换成苹果公司新提供的函数。

例如下面两个函数:

fileAttributesAtPath:traverseLink:

Returns a dictionary that describes the POSIX attributes of the file specified at a given.

 (Deprecated in Mac OS X v10.5. Use attributesOfItemAtPath:error: instead.)

- (NSDictionary *)fileAttributesAtPath:(NSString *) path traverseLink:(BOOL) flag
Parameters
path

A file path.

flag

If path is not a symbolic link, this parameter has no effect. If path is a symbolic link, then:

  • If YES the attributes of the linked-to file are returned, or if the link points to a nonexistent file the method returns nil.

  • If NO, the attributes of the symbolic link are returned.

Return Value

An NSDictionary object that describes the POSIX attributes of the file specified at path. The keys in the dictionary are described in “File Attribute Keys”. If there is no item at path, returns nil.


directoryContentsAtPath:

Returns the directories and files (including symbolic links) contained in a given directory. (Deprecated in Mac OS X v10.5. Use contentsOfDirectoryAtPath:error: instead.)

- (NSArray *)directoryContentsAtPath:(NSString *) path
Parameters
path

A path to a directory.

Return Value

An array of NSString objects identifying the directories and files (including symbolic links) contained in path. Returns an empty array if the directory exists but has no contents. Returns nil if the directory specified at path does not exist or there is some other error accessing it.

Discussion

The search is shallow and therefore does not return the contents of any subdirectories. This returned array does not contain strings for the current directory (“.”), parent directory (“..”), or resource forks (begin with “._”) and does not traverse symbolic links.

Special Considerations

Because this method does not return error information, it has been deprecated as of Mac OS X v10.5. Use contentsOfDirectoryAtPath:error: instead.

在ios5.0之后,dismissModalViewControllerAnimated方法被 dismissViewControllerAnimated:completion:方法所取代.后者比前者多了一个(void (^)(void))completion参数,这个参数是一个block用来提供UIViewcontroller对象被释放之后运行的回调.这个block的回调方法是在UIViewcontroller的viewDidDisappear: 之后被调用.  与以上的两个方法对应的方法是presentModalViewController:animated:和presentViewController:animated:completion:.


 类似资料:

相关阅读

相关文章

相关问答