nsmutablearray

Memory leak with returned NSMutableArray from function

半腔热情 提交于 2019-12-12 04:04:16
问题 I'm having problems with the implementation of the memory management of objective c. I've reed several manuals, but i think that I'm loosing something. I'm developing an application that uses a UITableView that is loaded with the results of a query; -(NSMutableArray *)sqlReader:(NSString *)sqlString { NSMutableArray *sqlResult = [[[NSMutableArray alloc] init] autorelease]; NSMutableArray *sqlRow = [[NSMutableArray alloc] init]; sqlite3 *database; int dataType; int intResult; int colCount; int

Nsmutablearray insertobject atindex but move down already inserted objects

坚强是说给别人听的谎言 提交于 2019-12-12 03:19:21
问题 I wanted to ask if the following scenario is somehow possible to happen. I have an Nsmutablearray and i have in it 5 objects. I load the Nsmutablearray on an uitableview. I want to insert a new object at the top of the other five objects but also move down all the previously inserted objects down by one. let me give you an example 0 one 1 two 2 three 3 four 4 five i want to result like this after the new object inserted on the top 0 six 1 one 2 two 3 three 4 four 5 five Any help appreciated.

Binary search warning in CFArrayBSearchValues

久未见 提交于 2019-12-12 02:34:14
问题 i'm using CFArrayBSearchValues . Ref: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFArrayRef/Reference/reference.html#//apple_ref/doc/uid/20001192-CH201-F10956 It works successfully but compiler show me a warning on first parameter: CFIndex indexResult = CFArrayBSearchValues( m_Locations, CFRangeMake(0, [m_Locations count]), data, PGPlaceDataCompare, nil); CFArrayBSearch expect as first parameter an CFArrayRef . My m_Locations is an NSMutableArray . How to

Trouble with adding item into an NSMutableArray inside a block

断了今生、忘了曾经 提交于 2019-12-12 02:04:02
问题 UPDATE: I just found a tricky part... if I do something like this, it works: [_friendsArrayInBlock insertObject:@"Bla" atIndex:itemIndex]; But it doesn't: [_friendsArrayInBlock insertObject:friend atIndex:itemIndex]; Why I cannot add a custom object, but I can add NSString? What's the problem ORIGINAL PART: Here you can see the relevant code part: @implementation ORGFriendsTableViewController { NSMutableArray *_friendsArray; } - (void)viewDidLoad { [super viewDidLoad]; _friendsArray =

TableViewCells and Array of Dictionaries

扶醉桌前 提交于 2019-12-12 01:41:10
问题 I am having trouble understanding how to populate my table with all the dates. returns only the day 9-1-2012 not 8-31-2012. I have tried a few things like using my days and slots in numberofrowssection. I am thinking it has something to do with .count but am not seeing where. But I have not figured it out yet. It still is only posting 9/1 dictionary. How do I display all the array of dictionaries in tableviewcell, I hope I am making sense, picture attached. My code: NSDictionary *json =

How to dynamically create a 2d NSMutableArray with loops

一个人想着一个人 提交于 2019-12-12 01:40:58
问题 I made an original post here At first, I tried to fill up a CGPoint **allPaths. With the first dimension being "a path" and the second dimension being "the waypoint". And I get a CGPoint out of this. For example : allPaths[0][2] would give me the CGPoint of the first path, third waypoint. I successfully did it in plain C with nasty loops. And now I am trying to do the same thing in Obj-C with NSMutableArrays. Here is my code : CCTMXObjectGroup *path; NSMutableDictionary *waypoint; int

Sort NSMutableArray

梦想的初衷 提交于 2019-12-12 01:35:07
问题 please help me I want to sort NSMutableArray and yes I can do this by NSSortDescriptor *sortPoint = [[NSSortDescriptor alloc] initWithKey:@"point" ascending:YES]; [hightScore sortUsingDescriptors:[NSArray arrayWithObject:sortPoint]]; but in NSMuatableArray(hightScore), I have 2 NSMutableDictionary like this [item setObject:@"player_name" forKey:@"name"]; [item setObject:@"100" forKey:@"point"]; and when I sort by keyword "point" that is string it give me like this 100 > 20 > 30 > 50 instead

IOS ARC NSMutableArray do I need to removeAllObjects before alloc new memory for it

风流意气都作罢 提交于 2019-12-12 01:33:25
问题 NSMutableArray * arrayTest; -(void) setContent { //must I call [array removeAllObjects]; ? arrayTest = [[NSMutableArray alloc] init] [arrayTest addObject:@"str"]; ...//add many objects } I call this function at different code snippet. do I need to removeAllObjects of arrayTest before , then alloc memory for arrayTest every time ? I use ARC . I don't want my app memory to increase every time I call this function. 回答1: No, what you have is fine. You don't need to call removeAllObjects under ARC

Custom Object Initialization does not store NSMutableArray objects with addObject:

两盒软妹~` 提交于 2019-12-12 01:31:40
问题 In creating a login screen with static logins I'm trying to store them privately in the following class implementation. When a button creates IONServer objects I initialize it with the function -(void)login:(NSString *)username password:(NSString *)pw and pass it two UITextField.text strings. If you notice in the init I am testing stuff with NSLog but at every breakpoint it seems like the storedLogins NSMutable array is nil . IONServer.m #import "IONServer.h" #import "IONLoginResult.h"

How to copy custom NSObject into NSMutableArray

左心房为你撑大大i 提交于 2019-12-12 00:29:15
问题 NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error]; NSArray* users = [json objectForKey:@"Users"]; NSEnumerator* enumerator = [users objectEnumerator]; id element; NSMutableArray *results; Result *fetchedResults; while(element = [enumerator nextObject]) { // fetchedResults = [[Result alloc] init]; // i have tried commenting/uncommenting fetchedResults.name = (NSString *)[[element objectForKey:@"User"] objectForKey:@"name"];