简体   繁体   English

iOS从资产目录创建文件名列表

[英]iOS create file name list from asset catalog

I am using asset catalog for emoji. 我将资产目录用于表情符号。 The question is, how I could get all emoji file list from asset catalog to prevent hard coded array of file names? 问题是,如何从资产目录中获取所有表情符号文件列表,以防止对文件名进行硬编码数组?

I tried to create run script., but it's not working. 我试图创建运行脚本。但是它不起作用。 creating txt file and put directory path only 创建txt文件并仅放置目录路径

for file in "./Images.xcassets/Smiles/"; do
echo $file >> ./Sparkle/smiles.txt
done

Maybe anyone could help me with this or other solution. 也许任何人都可以用这个或其他解决方案来帮助我。 Thanks 谢谢

Ok, there is solution to create txt file with specific file list: 好的,有一种创建带有特定文件列表的txt文件的解决方案:

Run Script: 运行脚本:

rm './Sparkle/smiles.txt'
for file in './YOURAPP/Resources/Images.xcassets/Smiles/smile_*'; do
filename=$(basename $file | cut -f 1 -d '.')
echo -e "$filename\n" > './YOURAPP/smiles.txt'
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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