nsmutablearray

shuffle NSMutableArray without repetition and showing in a UIButton

Deadly 提交于 2019-12-22 11:27:21
问题 In my view, i have 12 buttons,and a array contains 6 names , i want to print the array names in UIButton title. Here's my code: texts = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",nil]; UIButton *button; NSString *name; NSUInteger count = [texts count]; int i=0; for(UIView *view in self.view.subviews) { if([view isKindOfClass:[UIButton class]]) { button= (UIButton *)view; if(button.tag >= 1||button.tag <= 20) { int value = rand() % ([texts count] -1) ; int myTag= i+1

shuffle NSMutableArray without repetition and showing in a UIButton

人走茶凉 提交于 2019-12-22 11:26:19
问题 In my view, i have 12 buttons,and a array contains 6 names , i want to print the array names in UIButton title. Here's my code: texts = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",nil]; UIButton *button; NSString *name; NSUInteger count = [texts count]; int i=0; for(UIView *view in self.view.subviews) { if([view isKindOfClass:[UIButton class]]) { button= (UIButton *)view; if(button.tag >= 1||button.tag <= 20) { int value = rand() % ([texts count] -1) ; int myTag= i+1

NSMutable array to UITableview when button clicked

与世无争的帅哥 提交于 2019-12-22 09:55:19
问题 i want to show my email headers in a UITableView when inbox button clicked, my email headers is stored in an NSMutable Array, -(IBAction)buttonInbox:(id)sender{ NSLog(@"Inbox Button Clicked %@",buttonInbox); [self select:@"INBOX"]; NSArray *lines = [self sendCommand:@"fetch 1:* (body[header.fields (from subject date)])"]; //NSMutableArray *emaiArray= [[NSMutableArray alloc] init]; NSMutableString *totalEmail= [NSMutableString stringWithString:@""]; int counter = 0; int i =0; NSRange tmp; for

UserDefaults/KeyedArchiver Frustrations

佐手、 提交于 2019-12-22 09:30:00
问题 I'm working on a homework app that uses custom Assignment objects for each assignment. I am trying to store an NSMutableArray (casted to an NSArray via initWithArray:) in standardUserDefaults but I'm having trouble with saving and reloading the array. I have a table view from which you can choose to add a new assignment (which loads NewAssignmentViewController). When you save the assignment, it is pushed back to an array in AssigmentsViewController. And then you call it every time you load

Change a value within a NSMutableArray

喜你入骨 提交于 2019-12-22 06:53:03
问题 I have a NSMutableArray that is loaded with values. Later in the application, I need to change the values of one of the elements in the array. How do I accomplish this? thanks tony 回答1: Take a look at the class reference instance methods: http://developer.apple.com/library/ios/#documentation/cocoa/reference/foundation/Classes/NSMutableArray_Class/Reference/Reference.html You can use: replaceObjectAtIndex:withObject: given you know the index of the object. replaceObjectsAtIndexes:withObjects:

NSArray out of bounds check

Deadly 提交于 2019-12-22 01:39:17
问题 noobie question.. What is the best way to check if the index of an NSArray or NSMutableArray exists. I search everywhere to no avail!! This is what I have tried: if (sections = [arr objectAtIndex:4]) { /*.....*/ } or sections = [arr objectAtIndex:4] if (sections == nil) { /*.....*/ } but both throws an "out of bounds" error not allowing me to continue (do not reply with a try catch because thats not a solution for me) Thanks in advance 回答1: if (array.count > 4) { sections = [array

NSArray out of bounds check

旧时模样 提交于 2019-12-22 01:36:20
问题 noobie question.. What is the best way to check if the index of an NSArray or NSMutableArray exists. I search everywhere to no avail!! This is what I have tried: if (sections = [arr objectAtIndex:4]) { /*.....*/ } or sections = [arr objectAtIndex:4] if (sections == nil) { /*.....*/ } but both throws an "out of bounds" error not allowing me to continue (do not reply with a try catch because thats not a solution for me) Thanks in advance 回答1: if (array.count > 4) { sections = [array

How to use NSDate formatter with an array of dates?

☆樱花仙子☆ 提交于 2019-12-22 01:07:40
问题 I'm trying to generate an array of 30 days from the current date and put them into an array formatted correctly. I currently have a working generater to get 30 days from the current date and put it into an array but I don't know how to use NSDate formatter for an array. I know how to use the formatter for a single item but how can I format all the dates in my array? The format that I would like is (Month Day). Here's my code: NSMutableArray* dates = [[NSMutableArray alloc] init]; int

iPhone/iOS How to load a lot of image in many folder and show in a table view?

空扰寡人 提交于 2019-12-21 20:19:26
问题 I got annoying question... What if I have many image , and I want load it in to a table view And show the file name as cell's text , and the preview image is also show in the cell. When I select the cell , it will push to next view , show the big size image. That's it . I don't know how to load many folder to an array? /*********** EDIT ***********/ This is the folder I set many images inside You can see that's only one root folder ... And this is my code to load the image inside

How to implement “group by values” in NSMutableArray?

笑着哭i 提交于 2019-12-21 09:33:42
问题 I am using NSMutableArray. I want to fetch the values by date like we do in SQL group by "log_date" . logMuArray ( { "log_currenttime" = "4:30pm"; "log_date" = "11.12.2011"; "log_duration" = "1:30"; }, { "log_currenttime" = "4:33pm"; "log_date" = "11.12.2011"; "log_duration" = "2:21"; }, { "log_currenttime" = "4:40pm"; "log_date" = "11.12.2011"; "log_duration" = "5:30"; }, { "log_currenttime" = "7:30pm"; "log_date" = "12.12.2011"; "log_duration" = "1:30"; }, { "log_currenttime" = "7:33pm";