nsmutablearray

iPhone: Return NSMutableArray in method while still releasing

给你一囗甜甜゛ 提交于 2019-12-08 05:36:07
问题 I am trying to understand a little more about memory management. Knowing that I need to release anything that I have init or alloc'ed I am confused about the following: - (NSMutableArray *)getData { NSMutableArray *data = [[NSMutableArray alloc] init]; NSString *first = @"First object"; [data addObject:first]; NSString *second = @"Second object"; [data addObject:second]; return data; } Since I used alloc and init, I know I need to release my data object. But if I add autorelease to the init

Why does arrays handle strings containing swedish ÅÄÖ characters by using two or more indexes?

老子叫甜甜 提交于 2019-12-08 03:11:48
问题 Ok, my problem is that whenever i collect data from the parser into an array where the string contains Swedish ÅÄÖ characters. In my example the [schemaInfoArray objectAtIndex:3] is supposed to be @"Lördag" but is saved as @"L" and the [schemaInfoArray objectAtIndex:4] contains the rest of the string that gets presented as @"ördag" -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { tempStrang = string; [schemaInfoArray insertObject:tempStrang atIndex:uppraknare];

UIBezierPath undo drawing redraw UIImageView's image

妖精的绣舞 提交于 2019-12-08 02:54:05
问题 I'm trying to redraw my UIImageView's image by redrawing all UIBezierPaths and associated UIColors in an NSMutableArray I have created, minus the last path when I tap an undo UIButton. However, the UIImageView's image doesn't redraw and remove the last path in this case, until the NSMutableArray's count is less than 2, in which it sets the UIImageView's image to nil (this is working correctly) I'd appreciate any help offered. Note: I'm not including my touchesMoved method because I just want

How to group an NSMutableArray and show in UITableView?

梦想与她 提交于 2019-12-08 01:50:56
问题 I get json from server and add them in NSMutableArray like this: { "title": "title60", "summary": "summary60", "datetime": "2013.02.03", } { "id": 58, "title": "title59", "summary": "summary59", "datetime": "2013.02.03", }, { "id": 57, "title": "title58", "summary": "summary58", "datetime": "2013.02.04", }, { "id": 56, "title": "title57", "summary": "summary57", "datetime": "2013.02.04", }, { "id": 55, "title": "title56", "summary": "summary56", "datetime": "2013.02.05", } How can I use the

Adding objects in Multidimensional NSMutableArray

跟風遠走 提交于 2019-12-08 01:22:47
问题 I'm quite confused on how to add objects in multidimensional arrays. Is initializing multidimensional arrays are the same with just a simple array? This is my initialization. testList = [[NSMutableArray alloc] init]; I need to do something like testList[i][j] = item; i tried [[[testList objectAtIndex:i]objectAtIndex:j] addObject:item]; but it doesn't seem to work :( 回答1: You are add to much C to do this. This is important to know how to NSMutableArray works and how it's different compare to

Convert array to NSAttributedString

孤者浪人 提交于 2019-12-07 21:38:42
问题 I have a NSMutableArray composed of NSAttributedString 's. I'm trying to convert it to a single NSAttributedString separating all the NSAttributedString 's with a character. This approach is similar to the conversion of an array to a NSString with the componentsJoinedByString:@"," method but unfortunately this method doesn't exist with the NSAttributedString . How can I convert the array? Thanks. 回答1: I'd to the old way: NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]

how to sort the time in a NSMutableArray in ios

廉价感情. 提交于 2019-12-07 20:12:52
问题 i'm having a set of Dictionaries in a NSMutableArray. now i want to sort ascending & Descending order by time here is my Array value. ( { StartTime = "09:00 AM"; TravelsName = "ABC Travels"; }, { StartTime = "07:30 AM"; TravelsName = "XYZ Travels "; }, { StartTime = "06:45 PM"; TravelsName = "GSP Travels"; }, { StartTime = "05:00 PM"; TravelsName = "Madura Travels"; }, { StartTime = "12:45 AM"; TravelsName = "MJT Travels"; }, { StartTime = "12:45 PM"; TravelsName = "OPR Travels"; }, {

初学ios时候String的各种用法

♀尐吖头ヾ 提交于 2019-12-07 19:12:01
1. 学习方法 3 2. NSString 2.1. 创建常量字符串。 4 2.2. 创建空字符串,给予赋值。 4 2.3. 使用变量初始化 4 2.4. 判断是否包含某字符串 4 2.4.1. 检查字符串是否以另一个字符串开头- (BOOL) hasPrefix: (NSString *) aString; 4 2.4.2. 是否包含其它字符 5 2.5. 从文件读取字符串:initWithContentsOfFile方法 5 2.6. 写字符串到文件:writeToFile方法 5 2.7. 比较两个字符串 5 2.7.1. 用C比较:strcmp函数 5 2.7.2. isEqualToString方法 6 2.7.3. compare方法(comparer返回的三种值) 6 2.7.4. NSOrderedSame判断两者内容是否相同 6 2.7.5. 不考虑大小写比较字符串1 7 2.8. 改变字符串的大小写 7 2.9. 在串中搜索子串 7 2.10. 替换字符串 8 2.11. 分割字符串成数组 8 2.12. 字符串数组拼接成字符串 8 2.13. 抽取子串 9 2.13.1. -substringToIndex: 从字符串的开头一直截取到指定的位置,但不包括该位置的字符 9 2.13.2. -substringFromIndex: 以指定位置开始

how to check if NSMutableArray element is NSNull or AnyObject

杀马特。学长 韩版系。学妹 提交于 2019-12-07 19:07:46
问题 I have a PersonsArray: NSMutableArray = [NSNull, NSNull, NSNUll, NSNull, NSNull, NSNUll, NSNull] . I needed seven slots that I then can fill with an Entity CoreData entry as AnyObject. I need to do a for in loop on this NSMutableArray... If the index slot is NSNull I want to pass to next index slot, if index slot is filled with my Object I want to execute code on this Object. example PersonsArray: NSMutableArray = [ NSNull, NSNull, NSNull, "<iswift.Person: 0x7f93d95d6ce0> (entity: Person; id:

NSMutableArray removeAllObjects beyond bounds exception

◇◆丶佛笑我妖孽 提交于 2019-12-07 15:22:18
问题 I have an NSMutableArray object called logBuffer, which holds log information and dumps it in a file every N lines. When that happens, I remove all its entries, with [logBuffer removeAllObjects] Sometimes this throws an exception: [__NSArrayM removeObjectAtIndex:]: index 7 beyond bounds [0 .. 6] I guess removeAllObjects internally iterates through all objects in the array, but I am not sure how it can go beyond its bounds. My only though is that there is another thread that manipulates the