nsdictionary

NSPredicate on nested array with NSDictionary as object

心已入冬 提交于 2020-02-16 05:25:49
问题 i have a NSDictionary like: { "2017-05-02" = ( { "always_valid" = 0; date = "2017-05-02"; from = "12:00"; to = "13:00"; }, { "always_valid" = 0; date = "2017-05-02"; from = "12:00"; to = "12:00"; }, { "always_valid" = 0; date = "2017-05-02"; from = "14:00"; "hourly_rate" = 12; to = "15:00"; } ); "2017-05-03" = ( { "always_valid" = 0; date = "2017-05-03"; from = "12:00"; to = "13:00"; } ); "2017-05-18" = ( { "always_valid" = 1; date = "2017-05-18"; from = "12:00"; to = "12:00"; } ); } i'm

NSPredicate on nested array with NSDictionary as object

假装没事ソ 提交于 2020-02-16 05:25:24
问题 i have a NSDictionary like: { "2017-05-02" = ( { "always_valid" = 0; date = "2017-05-02"; from = "12:00"; to = "13:00"; }, { "always_valid" = 0; date = "2017-05-02"; from = "12:00"; to = "12:00"; }, { "always_valid" = 0; date = "2017-05-02"; from = "14:00"; "hourly_rate" = 12; to = "15:00"; } ); "2017-05-03" = ( { "always_valid" = 0; date = "2017-05-03"; from = "12:00"; to = "13:00"; } ); "2017-05-18" = ( { "always_valid" = 1; date = "2017-05-18"; from = "12:00"; to = "12:00"; } ); } i'm

iOS应用数据存储的方式

橙三吉。 提交于 2020-02-15 16:53:01
iOS应用数据存储的方式 XML属性列表(plist)归档 preference(偏好设置) NSKeyedArchiver归档 SQLite3 Core Data 应用沙盒 每个iOS应用都有自己的应用沙盒(应用沙盒就是文件系统目录),与其他文件系统隔离。应用必须待在自己的沙盒里,其他应用不能访问该沙盒 应用沙盒结构分析 应用程序包:包含了所有的资源文件和可执行文件 Document:保存应用运行时生成的需要持久化的数据,iTunes同步设备时会备份该目录。例如,游戏应用可以将游戏存档保存在该目录。 tmp:保存应用运行时所需要的临时数据,使用完毕后再将相应的文件从该目录删除。应用没有运行时,系统也可能会清除该目录下的文件。iTunes同步设备时不会备份该目录。 Library/Caches:保存应用运行时生成的需要持久化的数据,iTunes同步设备时不会备份该目录。一般存储体积大、不需要备份的非重要数据 Library/Preference:保存应用的所有偏好设置,iOS的Settings(设置)应用会在该目录中查找应用的设置信息。iTunes同步设备时会备份该目录 应用沙盒目录的常见获取方式 1. tmp:NSString *tmp= NSTemporaryDirectory( ); 2. Library/Caches:(跟Document类似的有两种方法)

ios应用数据存储方式

心已入冬 提交于 2020-02-15 16:51:18
一、ios应用常用的数据存储方式 1.plist(XML属性列表归档) 2.偏好设置 3.NSKeydeArchiver归档(存储自定义对象) 4.SQLite3(数据库,关系型数据库,不能直接存储对象,要编写一些数据库的语句,将对象拆开存储) 5.Core Data(对象型的数据库,把内部环节屏蔽) 二、应用沙盒 每个iOS应用都有⾃己的应⽤沙盒(应用沙盒就是文件系统目录),与其他文件系统隔离。应⽤必须待在⾃己的沙盒里,其他应用不能访问该沙盒(提示:在IOS8中已经开放访问) 应⽤沙盒的文件系统⽬录,如下图所示(假设应用的名称叫Layer) 模拟器应⽤用沙盒的根路径在: (apple是⽤用户名, 7.0是模拟器版本) /Users/apple/Library/Application Support/iPhone Simulator/7.0/Applications 三、应用沙盒结构分析 应⽤程序包:(上图中的Layer)包含了所有的资源文件和可执行文件 Documents:保存应⽤运行时生成的需要持久化的数据,iTunes同步设备时会备份该目录。例如,游戏应用可将游戏存档保存在该目录 tmp:保存应⽤运行时所需的临时数据,使⽤完毕后再将相应的文件从该目录删除。应用没有运行时,系统也可能会清除该目录下的文件。iTunes同步设备时 不会备份该目录 Library/Caches

How do I parse this Flickr response?

荒凉一梦 提交于 2020-02-01 03:16:46
问题 I get this from a sample Flickr response in their api site: jsonFlickrApi({"method":{"_content":"flickr.test.echo"}, "format":{"_content":"json"}, "api_key":{"_content":"8038f7f7d7151ccbf6df2aa10b1b35ae"}, "stat":"ok"}) I can see the dictionary in there, right after the words jsonFlickApi. But how do I get rid of that leading text and put the dictionary into my NSDictionary? 回答1: Use the NSJSONSerialization class to parse the JSON data. Edit: The jsonFlickrApi(...) indicates that you're using

How to set object and keys to NSMutabledictionary in correct order [duplicate]

℡╲_俬逩灬. 提交于 2020-01-17 16:34:09
问题 This question already has answers here : How can i get Original order of NSDictionary/NSMutableDictionary? (5 answers) Closed 5 years ago . I am trying set objects for particular keys to an NSMutableDictionary in a for loop The code: for(int k =0;k<currenyArry.count;k++) { [_currenies setObject:@"0" forKey:currenyArry[k]]; } Here, _currenies is an NSMutableDictionary and currenyArry is an NSMutableArray . For example, currentArry is: [1,3,5,10,100,500,1000]; After setting the objects in

Sort Array of Dictionaries by NSDates within the Dictionaries

孤者浪人 提交于 2020-01-17 04:23:45
问题 I am creating an application with separate posts in it (similar to Instagram). Each post is a dictionary located in one big array. Within each dictionary their is an NSDate which I would like to sort the dictionaries by in order from newest to oldest. I have read similar questions but they are in objective C. I have a feeling NSSortDescriptor be a helpful method but am unsure on how to use it in this situation. Any help would be great, Thanks 回答1: If you’re writing in Swift, you’ll probably

Nesting arrays into NSDictionary object (Objective-C)

三世轮回 提交于 2020-01-16 18:59:24
问题 I would like to define tasks using NSDictionary, which I'd like to save in a plist file (I didn't have much luck with Core Data so far), but got stuck at two points: -- When using initWithObjectsAndKeys: I can change the data type to number or boolean, using NSDate's numberWithInt: and numberWithBool: methods, respectively. I can't seem to find the method to change the type to date though. I couldn't find anything like that in the documentation. -- The second problem I ran into was with the

Nesting arrays into NSDictionary object (Objective-C)

醉酒当歌 提交于 2020-01-16 18:58:09
问题 I would like to define tasks using NSDictionary, which I'd like to save in a plist file (I didn't have much luck with Core Data so far), but got stuck at two points: -- When using initWithObjectsAndKeys: I can change the data type to number or boolean, using NSDate's numberWithInt: and numberWithBool: methods, respectively. I can't seem to find the method to change the type to date though. I couldn't find anything like that in the documentation. -- The second problem I ran into was with the

iOS开发 给TableView增加SearchBar

无人久伴 提交于 2020-01-16 04:33:36
效果如图: 可以根据输入的关键字,在TableView中显示符合的数据。 图中分组显示和索引效果,前面的博文已经记录,不再赘述。下面的例子是基于前文的基础上修改的,所以文件名啥的,请参考前文。 第一步是在TableView上方添加一个Search Bar,这里有一点需要注意,必须先把TableView拖下来,留下空间放Search Bar,不要在Table View占满屏幕的情况下把Search Bar拖到Table View顶部。区别在于,使用后面的方法,Search Bar是作为Table View的Header部分添加的,而前面的方法,Search Bar是独立的。在添加索引功能时,如果作为Table View的Header添加,右侧的索引会遮住Search Bar的右边部分。Search Bar几个常用属性: Placeholder是提示,就是hint属性,Corretion是自动修正,一般设为NO,即不修正,Show Cancel Button是显示取消按钮,我这里勾选。选中Search Bar的情况下切换到Connections Inspector面板,delegate与File’s Owner建立连接(我们会在ViewController中支持UISearchBarDelegate协议)。与前面几篇文章的例子相 同