nsmutablearray

NSMutableArray writeToUrl

独自空忆成欢 提交于 2019-12-11 15:05:29
问题 Is it possible to use the: [NSMutableArray writeToURL:(NSString *)path atomically:(BOOL)AuxSomething]; In order to send a file (NSMutableArray) XML file to a url, and update the url to contain that file? for example: I have an array and I want to upload it to a specific URL and the next time the app launches I want to download that array. NSMutableArray *arrayToWrite = [[NSMutableArray alloc] initWithObjects:@"One",@"Two",nil]; [arrayToWrite writeToURL: [NSURL urlWithString:@"mywebsite

Error Reading Copied NSMutableArray on iPhone SDK

梦想与她 提交于 2019-12-11 14:34:36
问题 In one of my methods, I fetched and parsed a JSON and placed it inside an NSArray called jsonArray in -(void)method1 . I then copied the contents of that jsonArray to an NSMutableArray called copiedJsonArray to be used on other methods. Problem is, copiedJsonArray crashes whenever I log its contents in the console from the other methods -(void)method2 but it logs fine in -(void)method1 . How can I fix this? In my header file: @interface MainViewController : UIViewController @property

Save and Load MapAnnotation pins using NSMutableArray

会有一股神秘感。 提交于 2019-12-11 13:38:55
问题 I need help with my MapAnnotation codes. I want to save map pins so that the user can come back to the map and see the ones he/she has placed. However this code does not show the pins when the view loads. Code for adding and saving pins: - (void)addPinToMap:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state != UIGestureRecognizerStateBegan) return; CGPoint touchPoint = [gestureRecognizer locationInView:self.mapView]; CLLocationCoordinate2D touchMapCoordinate = [self

How to check array value not exist in another array

删除回忆录丶 提交于 2019-12-11 13:11:46
问题 I have two different NSMutabelArray ArrOne and ArrTwo. Letsay ArrOne = A, B, C and D ArrTwo = C, D, X and Y. So i need to check if the value of ArrTwo is same as ArrOne and remove item from ArrTwo if it is not same as in ArrOne. In this case, i have to remove X and Y from ArrTwo. Please give me an idea. 回答1: NSMutableSet *set = [NSMutableSet setWithArray:arrOne]; [set intersectSet:[NSSet setWithAray:arrTwo]; return [set allObjects]; 回答2: You can do it with indexesOfObjectsPassingTest, like

separate future date in nsmutablearray

匆匆过客 提交于 2019-12-11 13:11:42
问题 I am having a mutable array in that array i am having only past date, current date & future date. I have to separate the future date & store into another array. Can you help me. This is my array: uniqueItems( "2015-03-01", "2015-02-28", "2015-02-22", "2015-02-21", "2015-02-20", "2015-02-15", "2015-02-14", "2015-02-13", "2015-02-08", "2015-02-07", "2015-02-01", "2015-01-31", "2015-01-30", "2015-01-25", "2015-01-24", "2015-01-18", "2015-01-17", "2015-01-16", "2015-01-11", "2015-01-10", "2014-12

How to parse this JSON response into a key & value pairs array

扶醉桌前 提交于 2019-12-11 12:04:48
问题 there are a lot of questions like this and i'm experienced with json format too but i couldnt parse the response below(at the bottom): I'm using NSJSONSerialization for parsing the response into NSDictionary but the it gives the error like below: My code: NSString *subURL= sharedDa.ip; NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://192.168.69.230/tsadmin.php?tssearch=%@", subURL]]]; NSError *error=nil; NSDictionary* portsResult=

writeToFile working in sim but not on device

蹲街弑〆低调 提交于 2019-12-11 11:53:32
问题 This code works on simulator but not on device. I am positive this has something to do with writing to file: NSString *path = [[NSBundle mainBundle] pathForResource:@"SongData" ofType:@"plist"]; NSArray *tempData = [[NSArray alloc] initWithContentsOfFile: path]; NSMutableArray *arr = [[NSMutableArray alloc] init]; for (NSDictionary *dict in tempData) { NSMutableDictionary *new = [[dict mutableCopy] autorelease]; if ([[new objectForKey:@"Song Title"] isEqualToString:[[tableData objectAtIndex:

NSMutableArray index mixed up

爷,独闯天下 提交于 2019-12-11 11:06:12
问题 I'm currently trying the iCarousel Multiple Carousel example. Here in my array, I've add images with NSMutableDictionary: I have two of these: ( myImages and myImages2 for my two slot in carousel loaded in ViewDidLoad) self.myImages = [NSMutableArray array]; for(int i = 0; i <= 10; i++) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [paths objectAtIndex:0]; NSString *savedPath = [documentsDir

Obj-C: using mutable and returning non mutable classes in methods

廉价感情. 提交于 2019-12-11 10:56:54
问题 In objective-C I find myself creating alot of Mutable objects and then returning them as non mutable objects. Is the way I am doing it here, simply returning the NSMutableSet as an NSSet a good practice? I was thinking maybe I should specify that i make a copy of it. /** Returns all the names of the variables used in a given * program. If non are used it returns nil */ + (NSSet *)variablesUsedInProgram:(id)program { NSMutableSet* variablesUsed = [[NSMutableSet alloc]init]; if ([program

App not functioning the same on 32 bit devices - NSInteger vs intValue

喜欢而已 提交于 2019-12-11 10:54:57
问题 I noticed after increasing the number of arrays that are instantiated into memory from 8 to 23, my app just stops running [NSMutableArray addObject:obj] on the 13th array on 32 bit devices only. On an iPad Air 2 (device and sim) and iPhone 6 (device and sim) all 23 arrays are populated and the app functions as expected. I understand there's a point at which a device will run out of available memory, and I noticed in Xcode on a 32 bit device, the app memory was hovering around 50-55mb , but