nsmutablearray

proper memory handling for an NSMutableArray assigned to property?

↘锁芯ラ 提交于 2019-12-31 06:57:28
问题 I have a property declared like this: @property (nonatomic, retain) NSMutableArray *pricingLevels; And I assign it like this: self.pricingLevels = [[[NSMutableArray alloc] init]; in my dealloc I have this: self.pricinglevels=nil; When I analyze my code with xCode it says I have a memory leak here: self.pricingLevels = [[[NSMutableArray alloc] init]; Should I be using an autolrelease on this because the self.pricinglevels holds a reference to the array also? 回答1: self.pricingLevels is a

proper memory handling for an NSMutableArray assigned to property?

Deadly 提交于 2019-12-31 06:57:11
问题 I have a property declared like this: @property (nonatomic, retain) NSMutableArray *pricingLevels; And I assign it like this: self.pricingLevels = [[[NSMutableArray alloc] init]; in my dealloc I have this: self.pricinglevels=nil; When I analyze my code with xCode it says I have a memory leak here: self.pricingLevels = [[[NSMutableArray alloc] init]; Should I be using an autolrelease on this because the self.pricinglevels holds a reference to the array also? 回答1: self.pricingLevels is a

why is my code outputting *nil description*

家住魔仙堡 提交于 2019-12-31 04:57:06
问题 Code: LotteryEntry.h #import <Foundation/Foundation.h> @interface LotteryEntry : NSObject { NSCalendarDate *entryDate; int firstNumber; int secondNumber; } - (void) prepareRandomNumbers; - (void) setEntryDate:(NSCalendarDate *)date; - (NSCalendarDate*)entryDate; - (int) firstNumber; - (int) secondNumber; @end LotteryEntry.m #import "LotteryEntry.h" @implementation LotteryEntry - (void) prepareRandomNumbers { firstNumber = random() % 100 + 1; secondNumber = random() % 100 + 1; } - (void)

how to add json and stepper value store in using button click event nsmutablearray in ios

爷,独闯天下 提交于 2019-12-31 01:43:09
问题 i am new in ios developer.i want to store json and stepper value.i have already store json and stepper value is nsmutablearray but problem is when i back to the screen that time this array new value is overwrite to old value.but i want to store old nad new value both.i upload my json response. { Data: [ { m_id: "1", m_name: "Shirts(Man)", m_drycleaning_price: "12", m_washiron_price: "25", m_wash_price: "10", m_iron_price: "9", m_imagename: "a" }, { m_id: "2", m_name: "Pants(Man)", m

insertObject: atIndex: - index 3 beyond bounds for empty array

不打扰是莪最后的温柔 提交于 2019-12-30 07:21:09
问题 I create an array based on a dictionaries key's: factsBuiltArray = [NSMutableArray arrayWithCapacity: 6]; if ([statusDict count] == 10) { for (NSString *key in [statusDict allKeys]) { if ([key isEqualToString: @"currenciesAndConversions"]) { [factsBuiltArray insertObject:key atIndex: 0]; } else if ([key isEqualToString: @"languageAndTranslations"]) { [factsBuiltArray insertObject:key atIndex: 1]; } else if ([key isEqualToString: @"plugSize"]) { [factsBuiltArray insertObject:key atIndex: 2]; }

crash while removing objects from NSMutableArray

非 Y 不嫁゛ 提交于 2019-12-30 05:48:05
问题 In my iphone project (ARC enabled) i have a nsmuatble array which contains some 5 managed objects (which are retrieved from core data ) and in some scenario i need to remove all the objects from that nsmutablearray i have used following methods to remove objects but its crashing in both the cases with the crash log -[__NSArrayI removeObject:]: unrecognized selector sent to instance 0xa391640 if (surveys && [surveys count]>0) { [surveys removeAllObjects]; surveys = [[NSMutableArray alloc]init]

Code Not Completing Before Next Method Is Called

烂漫一生 提交于 2019-12-29 09:33:07
问题 In my iOS app, I am using the forecast.io API to get a weather forecast for 3 specific days. Once I get the array from all 3, I want to create an NSMutableArray and add all of those objects to it. The problem I am getting is that it is trying to create the NSMutableArray before the forecast data is retrieved. Here is what I have so far: typedef void(^myCompletion)(BOOL); -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:YES]; [self myMethod:^(BOOL finished) { if(finished){

Empty NSMutableArray , not sure why

放肆的年华 提交于 2019-12-29 08:28:08
问题 Ok so I populate the array like this: NSMutableArray *participants; for(int i = 0; i < sizeofpm; i++){ NSDictionary *pmpart_dict = [pm_participants objectAtIndex:i]; NSString *pmpart_email = [pmpart_dict objectForKey:@"email"]; NSString *pmpart_email_extra = [@"pm" stringByAppendingString:pmpart_email]; [participants setValue:pmpart_email forKey:pmpart_email_extra]; NSLog(@"%@", participants); } sizeofpm is 1. that is using count. to get the number of values in the array. How can i store

Getting “mutating method sent to immutable object” error

99封情书 提交于 2019-12-29 01:54:06
问题 I can't figure out what is causing this. Basically, a few different 'tasks' are colliding with each other in my app. When i press a button, it runs this code just fine: PalAppDelegate *dataCenter = (PalAppDelegate *)[[UIApplication sharedApplication] delegate]; [dataCenter.colourPalettesContainer addObject:[NSNumber numberWithInt:5]]; It can do this as many times as i like. But when i perform another task (and theres a few which cause this to happen), which involves this code for example:

Saving an NSMutableArray to Core Data

无人久伴 提交于 2019-12-28 09:18:24
问题 I want to add an NSMutableArray of NSStrings to one of my Entities in my core data model. The problem is that this isn't a supported type in Core Data. I tried making a tranformable attribute, but the problem is that I see no way of turning a NSMutableArray to NSData, and then going from NSData, back to an NSMutableArray. Does anyone have an idea as to how this issue can be solved? (I know I can archive the array, but I don't want to do that, I want it to be present in my model). 回答1: You