c/c++语言开发共享Object-C,遍历目录

  最近武汉连续下雨很多天,降温了2次,温度一下子由28度到14度,再到8度,手太冷了。 加上最近发生了一些比较棘手的家庭琐事,最近没心情继续学习object-c。 后来,我想明白了,心情

 

最近武汉连续下雨很多天,降温了2次,温度一下子由28度到14度,再到8度,手太冷了。

加上最近发生了一些比较棘手的家庭琐事,最近没心情继续学习object-c。

后来,我想明白了,心情不好的时候,还是应该坚持学习。

郁郁寡欢,于事无补,该干嘛干嘛去~

不开心的事情,总会过去的。等过去之后,该做的事情总是要继续做的。

因为不开心,浪费不少大好时间,才是雪上加霜的。

计划2015和2016年,初步掌握ios开发。

一个人可以独自开发ios应用,看得懂、能够维护别人已经写好的app。

android也是必须同时深入学习的。

我现在的初步感觉是,android上手容易,但是因为开源可以有更多内容需要学习。

而object-c和ios开发,上手男很多,但是要学习的内容会少很多。

mac,这么小的mac,开发打字效率好低啊,让人着急额~最近搞得多了,稍微快了一些。

 

  //  //  main.m  //  filepath  //  //  created by fansunion on 15/11/29.  //  copyright (c) 2015年 demo. all rights reserved.  //    #import     //enumeratoratpath 遍历目录,如果目录下有目录,递归遍历  //contentsofdirectoryatpath 只遍历目录  //比较尴尬的是,“当前工作目录”下,只有1个文件,有点奇怪  //所以最后手动,遍历“/users/fansunion”/下的文件,只能简单地看看这个目录下的文件(目录)列表  int main(int argc, const char * argv[]) {      @autoreleasepool {          nsstring *currentpath;          nsstring *temppath;          nsfilemanager *fm;          nsdirectoryenumerator *direnum;          nsarray *dirarray;                    //文件管理器的实例          fm = [nsfilemanager defaultmanager];          //获取当前工作目录的路径          currentpath = [fm currentdirectorypath];          nslog(@"the path is %@!",currentpath);          //枚举目录          direnum =[fm enumeratoratpath:currentpath];            while((temppath=[direnum nextobject])!= nil){              nslog(@"%@",temppath);          }                    //另外一种枚举目录的方法          dirarray= [fm contentsofdirectoryatpath:currentpath error:null];          nslog(@"%@",dirarray);          for(temppath in dirarray){               nslog(@"%@",temppath);          }                    dirarray =[fm contentsofdirectoryatpath:@"/users/fansunion" error:null];          nslog(@"%@",dirarray);        }      return 0;  }

 

程序输出

 

2015-11-29 13:02:49.528 filepath[2750:159478] the path is /users/fansunion/library/developer/xcode/deriveddata/filepath-dfjiajapcipfrbcbfjmxijqhscws/build/products/debug!

2015-11-29 13:02:49.534 filepath[2750:159478] filepath

2015-11-29 13:02:49.534 filepath[2750:159478] (

filepath

)

2015-11-29 13:02:49.534 filepath[2750:159478] filepath

2015-11-29 13:02:49.535 filepath[2750:159478] (

".bash_history",

".cfusertextencoding",

".ds_store",

".ssh",

".subversion",

".trash",

desktop,

documents,

downloads,

library,

movies,

music,

pictures,

public

)

program ended with exit code: 0

 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/606054.html

(0)
上一篇 2021年5月13日
下一篇 2021年5月13日

精彩推荐