`
- 浏览:
746815 次
- 性别:
- 来自:
北京
-
2、播放音乐:-(void)
playMusic{@try{//取文件路径NSString*musicFilePath
= [[NSBundlemainBundle]pathForResource:@"startLogo"ofType:@"mp3"];
NSURL*musicURL
= [[NSURLalloc]initFileURLWithPath:musicFilePath];
musicPlayer=
[[AVAudioPlayeralloc]initWithContentsOfURL:musicURLerror:nil];[musicURLrelease];//[musicPlayer prepareToPlay];//[musicPlayer setVolume:1];
//设置音量大小musicPlayer.numberOfLoops=0;//设置播放次数,-1为一直循环,0为一次[musicPlayerplay];}@catch(NSException*
e) {}}******************************************************************************//******************************************************************************3、每隔0.8秒执行timeCount方法:NSTimer*countTimer;countTimer=
[NSTimerscheduledTimerWithTimeInterval:0.8target:selfselector:@selector(timeCount:)userInfo:nilrepeats:YES];
[countTimerfire];
//执行timer******************************************************************************//******************************************************************************4、延迟1秒执行test方法:[selfperformSelector:@selector(test)withObject:nilafterDelay:0.1];******************************************************************************//******************************************************************************5、启动线程:[NSThreaddetachNewThreadSelector:@selector(transImage)toTarget:selfwithObject:nil];timer=[NSTimerscheduledTimerWithTimeInterval:0.03target:selfselector:@selector(TimerClock:)userInfo:nilrepeats:YES];//启动一个NSTimer执行广播[timerfire];//执行timer-(void)TimerClock:(id)sender{//控制延迟触发if(Timecontrol>1)
{ [timerConditionbroadcast];
//广播,触发处于等待状态的timerCondition}}-(void)transImage{isRunning=YES;while(countTime<COUNTTIME)
{[timerConditionwait];lim+=255/
(2*KFrame);[selfprocessImage];countTime+=1000/KFrame;}[timerinvalidate];isRunning=NO;}******************************************************************************//******************************************************************************6、获取文件路径://通过NSHomeDirectory获得文件路径NSString*homeDirectory
=NSHomeDirectory();NSString*fileDirectory
= [homeDirectorystringByAppendingPathComponent:@"temp/app_data.plist"];//使用NSSearchPathForDirectoriesInDomains检索指定路径NSArray*path
=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);//常量NSDocumentDirectory表示正在查找Documents目录的路径(使用NSCachesDirectory表明要查找的时Caches文件夹),常量NSUserDomainMask表明我们希望将搜索限制于我们应用程序的沙盒,最后一个参数决定了是否“展开”波浪线符号。//在Mac系统中,‘~’表示主路经(Home),如果不展开,路径看起来就是:‘~/Documents’,展开后即得到完整路径。这个参数一直设置位真即可。NSString*documentsDirectory
= [pathsobjectAtIndex:0];zNSString*fileDirectory
= [documentsDirectorystringByAppendingPathComponent:@"file.txt"];//使用Foundation中的NSTemporaryDirectory函数直接返回代表temp文件夹的全路径的字符串对象NSString*tempDirectory
=NSTemporaryDirectory();NSString*file
= [tempDirectorystringByAppendingPathComponent:@"file.txt"]; Example:NSArray*path
=NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES);NSString*docDir
= [pathobjectAtIndex:0];NSLog(@"filepath:%@",docDir);NSString*str
=@"hello.jpg";NSString*filepath
= [docDirstringByAppendingPathComponent:str];//NSString *filepath = [docDir
stringByAppendingPathComponent:[NSString stringWithUTF8String:"///mest.txt"]];NSLog(@"filepath:%@",filepath);BOOLsuccess
= [[NSFileManagerdefaultManager]createFileAtPath:
filepathcontents:nilattributes:nil];NSLog(@"result",success);printf("Create
File:%s %s.",[filepathUTF8String],
success ?"Success":"Error");NSString*
reValue= [NSStringstringWithString:@"\"success\""];NSLog(reValue);******************************************************************************//************************************************************************************************************************************************************7文件、文件夹操作//如果"/Documents/Theme"路径不存在,则创建。if(![[NSFileManagerdefaultManager]fileExistsAtPath:themePath]){[[NSFileManagerdefaultManager]createDirectoryAtPath:themePathattributes:nil];}//删除已存在的同名文件夹if([[NSFileManagerdefaultManager]fileExistsAtPath:savePath])
{[[NSFileManagerdefaultManager]removeItemAtPath:savePatherror:NULL];}************************************************************************************************************************************************************//************************************************************************************************************************************************************7子线程抛给主线程:[selfperformSelectorOnMainThread:@selector(shiftView)withObject:nilwaitUntilDone:YES];************************************************************************************************************************************************************//************************************************************************************************************************************************************8获取当前时间NSDateFormatter*formatter
= [[NSDateFormatteralloc]init];[formattersetDateFormat:@"yyyy-MM-dd
hh:mm:ss"];NSString*locationString=[formatterstringFromDate:
[NSDatedate]];//获取当前时间作为productIdNSDateFormatter*formatter
= [[NSDateFormatteralloc]init];[formattersetDateFormat:@"hhmmss"];NSString*locationString=[formatterstringFromDate:
[NSDatedate]];downloadInfo.productId = locationString;[formatterrelease];/******************************************************************************函数名称 : getDate函数描述 : 获取当前日期时间输入参数 : N/A输出参数 : N/A返回值 : NSString 当前时间备注 :******************************************************************************/-(NSString*)getDate{NSDateFormatter*formatter
= [[NSDateFormatteralloc]init];[formattersetDateFormat:@"yyyy-MM-dd
EEEE HH:mm:ss a"];NSString*locationString=[formatterstringFromDate:
[NSDatedate]];[formatterrelease];returnlocationString;}大写的H日期格式将默认为24小时制,小写的h日期格式将默认为12小时不需要特别设置,只需要在dataFormat里设置类似"yyyy-MMM-dd"这样的格式就可以了日期格式如下:y年Year1996; 96M年中的月份MonthJuly; Jul; 07w年中的周数Number27W月份中的周数Number2D年中的天数Number189d月份中的天数Number10F月份中的星期Number2E星期中的天数TextTuesday; TueaAm/pm 标记TextPMH一天中的小时数(0-23)Number0k一天中的小时数(1-24)Number24Kam/pm 中的小时数(0-11)Number0ham/pm 中的小时数(1-12)Number12m小时中的分钟数Number30s分钟中的秒数Number55S毫秒数Number978z时区General time zonePacific Standard Time; PST; GMT-08:00Z时区RFC 822 time zone-0800************************************************************************************************************************************************************//************************************************************************************************************************************************************读取和写入plist文件plist文件是标准的xml文件,在cocoa中可以很简单地使用。这里介绍一下使用方法: 以下代码在Mac和iPhone中均适用。写入plist文件: NSMutableDictionary * dict = [ [NSMutableDictionaryalloc
] initWithplist文件是标准的xml文件,在cocoa中可以很简单地使用。这里介绍一下使用方法: 以下代码在Mac和iPhone中均适用。 写入plist文件:NSMutableDictionary* dict
= [ [NSMutableDictionaryalloc
]initWithContentsOfFile:@"/Sample.plist"];[ dictsetObject:@"Yes"forKey:@"RestartSpringBoard"];[ dictwriteToFile:@"/Sample.plist"atomically:YES]; 读取plist文件: NSMutableDictionary* dict
= [ [NSMutableDictionaryalloc
]initWithContentsOfFile:@"/Sample.plist"];NSString*
object = [ dictobjectForKey:@"RestartSpringBoard"];************************************************************************************************************************************************************/
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
MarkMark是一款简单设计标注、测量工具。MarkMark有着自动测量区域像素、放大区域等功能。MarkMark也是一款很轻巧的、易操作的工具。需要对图像进行精细测量的朋友不试试这款软件。 MarkMark功能 MarkMark是一款...
MarkText是一个MIT许可的开源项目,最新的版本可以从GitHub发布页面免费下载。MarkText还在发展中,它的发展离不开所有的赞助商。 特点: 实时预览(所见即所得)和一个干净和简单的界面。 支持CommonMark Spec, ...
marktext的中文包marktext的中文包
MarkMark.exe MarkMark是一款非常实用的最新图片测量软件。这款图像测量系统同时也是一款简单设计标注、测量工具,它有自动测量区域像素、放大区域等功能,适用于需要对图像进行精确测量的用户使用!
MCU coremark 源代码,移植到需要测试的MCU平台即可。通过串口打印显示分数
Mark点匹配算法,一个开卷设备,有一盘料带,一行有16个件,料带上有若干行,CCD去一行一行的检测,当检测到其中一行有一个或多个不良的工件时,会把不良工件的位置坐标给PLC(主要是给行坐标,也就是这一行上的第几...
开发工具Markdown工具marktext-x64-win免安装版
我的Mark笔记工具,可以上传了吗
marktext-Windows安装包marktext下载地址
Mark5C Software Development
EOS 5D MARKIII评测总结.pdf 学习资料 复习资料 教学资源
MarkText是一款开源的MarkDown编辑器,来源于https://marktext.app。
参考网上资料移植的coremark到riscv芯片上,可以实现跑分,压缩包里有跑分结果
mark地址修改
mark移动端页面开发.zip
coremark 源代码 移植后,即可测试目标MCU的coremark评分 注意:该评分与编译器版本密切相关。
MarkMark是一款绿色小巧且简单实用的图像测量工具,为用户提供自动测量区域,像素,对图像进行精细测量,提供放大镜等功能,能让设计师更快捷高效的完成标注,使用MarkMark,标注从未变得如此简单。
2023最新版marktext软件下载,Mark Text 多模式形态编辑器 适用平台:macOS、Windows、Linux 这是一款基于 MIT 协议开源的 Markdown 编辑器,支持 WYSIWYG(所见即所得)的编辑方式,致力于给你提供一个专注的写作...
lenovo E49 Mark File
markText安装包,程序员必备笔记软件,代码插入简介方便。