首页 文章 精选 留言 我的

精选列表

搜索[ios],共10000篇文章
优秀的个人博客,低调大师

iOS - OC NSLocale 本地化信息

前言 @interface NSLocale : NSObject <NSCopying, NSSecureCoding> NSLocale 类返回本地化信息,主要体现在"语言"和"区域格式"这两个设置项。 1、NSLocale 本地化信息的创建 // 用标示符创建 NSLocale *locale1 = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"]; // 返回系统初始本地化信息 NSLocale *locale2 = [NSLocale systemLocale]; // 一直保持在 cache 中,第一次用此方法实例化对象后,即使修改了本地化设定,也不改变 NSLocale *locale3 = [NSLocale currentLocale]; // 每次修改本地化设定,其实例化的对象也会随之改变 NSLocale *locale4 = [NSLocale autoupdatingCurrentLocale]; 2、NSLocale 本地化信息的设置 NSCalendar *calendar = [NSCalendar currentCalendar]; [calendar setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"]]; 3、NSLocale 本地化信息的获取 // 根据不同的 key 返回各种本地化信息 NSString *strSymbol = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencySymbol]; NSCalendar *calendar = [[NSLocale currentLocale] objectForKey:NSLocaleCalendar]; 4、显示特定地区代号下相应键的显示名称 NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"]; NSString *str = [locale displayNameForKey:NSLocaleIdentifier value:@"en_US"];

优秀的个人博客,低调大师

iOS - Swift NSLocale 本地化信息

前言 public class NSLocale : NSObject, NSCopying, NSSecureCoding NSLocale 类返回本地化信息,主要体现在"语言"和"区域格式"这两个设置项。 1、NSLocale 本地化信息的创建 // 用标示符创建 let locale1:NSLocale = NSLocale(localeIdentifier: "zh_CN") let strSymbol:AnyObject? = locale1.objectForKey(NSLocaleCurrencySymbol) // 返回系统初始本地化信息 let locale2:NSLocale = NSLocale.systemLocale() let calendarIdentifier = locale2.objectForKey(NSLocaleCalendar)?.calendarIdentifier // 一直保持在 cache 中,第一次用此方法实例化对象后,即使修改了本地化设定,也不会改变 let locale3:NSLocale = NSLocale.currentLocale() // 每次修改本地化设定,其实例化的对象也会随之改变 let locale4:NSLocale = NSLocale.autoupdatingCurrentLocale() 2、NSLocale 本地化信息的设置 let calendar:NSCalendar = NSCalendar.currentCalendar() // 设置区域 calendar.locale = NSLocale(localeIdentifier: "zh_CN") 3、NSLocale 本地化信息的获取 let locale = NSLocale.currentLocale() // 根据不同的 key 返回各种本地化信息 let strSymbol:AnyObject? = locale.objectForKey(NSLocaleCurrencySymbol) let calendar:AnyObject? = NSLocale.currentLocale().objectForKey(NSLocaleCalendar) 4、显示特定地区代号下相应键的显示名称 let locale = NSLocale(localeIdentifier: "zh_CN") let str = locale.displayNameForKey(NSLocaleIdentifier, value: "en_US")

优秀的个人博客,低调大师

iOS - File Archive/UnArchive 文件压缩/解压

1、ZipArchive 方式 ZipArchive 只能对 zip 类文件进行压缩和解压缩 GitHub 网址:https://github.com/ZipArchive/ZipArchive ZipArchive 使用 ARC 添加 ZipArchive // 添加第三方库文件 ZipArchive // 包含系统动态库 libz.tbd (libz.dylib) // 包含头文件 #import "ZipArchive.h" ZipArchive 压缩 文件压缩 // 目标路径 NSString *destinationFilePath = @"/Users/JHQ0228/Desktop/test.zip"; // 源路径,待压缩的文件 NSArray *resourcesFilePaths = @[@"/Users/JHQ0228/Desktop/test1.rtf", @"/Users/JHQ0228/Desktop/test2.rtf"]; BOOL result = [SSZipArchive createZipFileAtPath:destinationFilePath withFilesAtPaths:resourcesFilePaths]; 文件夹压缩 // 目标路径 NSString *destinationFilePath = @"/Users/JHQ0228/Desktop/test.zip"; // 源路径,待压缩的文件夹 NSString *resourcesDirPath = @"/Users/JHQ0228/Desktop/test"; BOOL result = [SSZipArchive createZipFileAtPath:destinationFilePath withContentsOfDirectory:resourcesDirPath]; ZipArchive 解压缩 普通解压 // 源路径,待解压缩的文件 NSString *resourcesFilePath = @"/Users/JHQ0228/Desktop/test.zip"; // 目标路径 NSString *destinationDirPath = @"/Users/JHQ0228/Desktop/test"; BOOL result = [SSZipArchive unzipFileAtPath:resourcesFilePath toDestination:destinationDirPath]; 密码解压 // 源路径,待解压缩的文件 NSString *resourcesFilePath = @"/Users/JHQ0228/Desktop/test.zip"; // 目标路径 NSString *destinationDirPath = @"/Users/JHQ0228/Desktop/test"; BOOL result = [SSZipArchive unzipFileAtPath:resourcesFilePath toDestination:destinationDirPath overwrite:YES password:@"password" error:nil]; 协议解压 // 源路径,待解压缩的文件 NSString *resourcesFilePath = @"/Users/JHQ0228/Desktop/test.zip"; // 目标路径 NSString *destinationDirPath = @"/Users/JHQ0228/Desktop/test"; BOOL result = [SSZipArchive unzipFileAtPath:resourcesFilePath toDestination:destinationDirPath delegate:self]; 协议密码解压 // 源路径,待解压缩的文件 NSString *resourcesFilePath = @"/Users/JHQ0228/Desktop/test.zip"; // 目标路径 NSString *destinationDirPath = @"/Users/JHQ0228/Desktop/test"; BOOL result = [SSZipArchive unzipFileAtPath:resourcesFilePath toDestination:destinationDirPath overwrite:YES password:@"password" error:NULL delegate:self]; 协议方法 - (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total { NSLog(@"%f", (float)loaded/total); } 2、SARUnArchiveANY 方式 SARUnArchiveANY 可以对 .zip, .rar, .7z 类文件进行压缩和解压缩。 GitHub 网址:https://github.com/saru2020/SARUnArchiveANY SARUnArchiveANY 使用 ARC 添加 SARUnArchiveANY // 添加第三方库文件 SARUnArchiveANY // 包含系统动态库 libz.tbd (libz.dylib) // 包含头文件 #import "SARUnArchiveANY.h" #import "LZMAExtractor.h" SARUnArchiveANY 解压缩 - (void)unZip { NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Zip_Example" ofType:@"zip"]; NSString *destPath = [self applicationDocumentsDirectory]; [self unArchive:filePath andPassword:nil destinationPath:destPath]; } - (void)unRar { NSString *filePath = [[NSBundle mainBundle] pathForResource:@"example" ofType:@"rar"]; NSString *destPath = [self applicationDocumentsDirectory]; [self unArchive:filePath andPassword:nil destinationPath:destPath]; } - (void)unZip_pwd { NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Zip_Example_pwd" ofType:@"zip"]; NSString *destPath = [self applicationDocumentsDirectory]; [self unArchive:filePath andPassword:@"SARUnArchiveANY_ZIP" destinationPath:destPath]; } - (void)unRar_pwd { NSString *filePath = [[NSBundle mainBundle] pathForResource:@"example_pwd" ofType:@"rar"]; NSString *destPath = [self applicationDocumentsDirectory]; [self unArchive:filePath andPassword:@"SARUnArchiveANY_RAR" destinationPath:destPath]; } - (void)Unzip7z { NSString *archiveFilename = @"example.7z"; NSString *archiveResPath = [[NSBundle mainBundle] pathForResource:archiveFilename ofType:nil]; NSAssert(archiveResPath, @"can't find .7z file"); NSString *destPath = [self applicationDocumentsDirectory]; [self unArchive:archiveResPath andPassword:nil destinationPath:destPath]; } - (void)unArchive: (NSString *)filePath andPassword:(NSString*)password destinationPath:(NSString *)destPath { NSAssert(filePath, @"can't find filePath"); SARUnArchiveANY *unarchive = [[SARUnArchiveANY alloc] initWithPath:filePath]; if (password != nil && password.length > 0) { unarchive.password = password; } if (destPath != nil) { // (Optional). If it is not given, then the file is unarchived in the same location of its archive/file. unarchive.destinationPath = destPath; } unarchive.completionBlock = ^(NSArray *filePaths) { NSLog(@"For Archive : %@", filePath); if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"US Presidents://"]]) { NSLog(@"US Presidents app is installed."); [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"US Presidents://"]]; } for (NSString *filename in filePaths) { NSLog(@"File: %@", filename); } }; unarchive.failureBlock = ^(){ NSLog(@"Cannot be unarchived"); }; [unarchive decompress]; } - (void)handleFileFromURL:(NSString *)filePath { NSLog(@"********* FILES FROM THE OTHER APPS *********"); [self unArchive:filePath andPassword:nil destinationPath:nil]; } - (NSString *) applicationDocumentsDirectory { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; return basePath; }

优秀的个人博客,低调大师

[iOS]深入理解ivar及property

以下所有类和对象的描述均以Objective-C为参考, cpu架构为arm64 0x0 一句话描述类和对象与内存的关系 类本身是一个描述, 描述里包含实例化这个类需要多大的内存, 以及内存的每个byte是什么内容, 这个内容的头部是一个isa, 其他内容是ivar的值或指针. 对象是按类的描述所从内存空间里面开辟出对应大小的空间并填充isa指针(alloc), 类的初始化方法往这个空间里的byte里面存初始化的内容. 0x1 ivar 举个例子: @interface AClass : NSObject { NSString *_aString; NSInteger _aInt; } @end @implementation AClass - (instancetype)init { if (self = [sup

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码