nsarray

Search only in array's that set ON in settings

最后都变了- 提交于 2019-12-12 00:09:56
问题 I need to search and filter only in array's that set ON in settings. Now I loop in dict for all array's: - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"Name CONTAINS[cd] %@ OR Address CONTAINS[cd] %@", searchText, searchText]; searchResults = [NSMutableArray array]; for (NSString *akey in dict) { NSLog(@"%@", akey); NSArray *array = [dict objectForKey:akey]; NSArray *matches = [array

Check UIImageView array frame equality with NSTimer

大憨熊 提交于 2019-12-11 23:46:44
问题 I am wondering how to check if all the frames of two UIImageView NSMutableArray s are equal to each other. Now I am using a NSTimer for that. Here is the code which I used in the method: __block BOOL equal = YES; [Img1Array enumerateObjectsUsingBlock:^(UIImageView *ImageView1, NSUInteger idx, BOOL *stop) { UIImageView *ImageView2 = Img2Array[idx]; if (!CGRectEqualToRect(ImageView1.frame, ImageView2.frame)) { *stop = YES; equal = NO; } }]; if (equal) { NSLog(@"ALL THE FRAMES ARE EQUAL");

How to sort an Array of signed numbers in iOS?

*爱你&永不变心* 提交于 2019-12-11 20:21:42
问题 This may be a simple question, but i don't know the way of doing sorting of array of signed integer values. My array before sorting, pointsAry (-2,-7,-5,0,-3,2,-1,-4,1,3,-6) After using NSArray * sortedArray = [pointsAry sortedArrayUsingComparator:^(id str1, id str2){ return [(NSString *)str1 compare:(NSString *)str2 options:NSNumericSearch]; }]; Result sortedArray : (-1,-2,-3,-4,-5,-6,-7,0,1,2,3) for signed values the sortedArray format is not correct, so i need like (-7,-6,-5,-4,-3,-2,-1,0

How to specify a label to one specific storyboard?

做~自己de王妃 提交于 2019-12-11 20:14:32
问题 Basically I am making an app (a simple game) using storyboards where a question will pop up on the screen and the user has to answer it. They have the option to move onto the next question or to record their response. I have created an NSArray which has a list of questions and I want them to appear in a label randomly (the label will pick one of the questions from the NSArray at random to display). The way I want to do this though is so that each storyboard has a question so once one question

Japanese and chinese characters in ios

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 18:49:53
问题 I just had an error, at least different in Xcode. I tried to put support for another language in a few sentences of the app, when the user chooses to change the language the app accesses just another index of NSArray. What happens is that one of the languages ​​is Japanese, and ran a few sentences, others simply returned me the following: ( "\U5f62\U5f0f", "\U9023\U63a5\U5230\U5176\U4ed6\U5730\U65b9", "\U884c\U674e\U8a8d\U9818", "\U9322" ) The original NSArray was: JapaneseTableTitles = [

How add values from text field / label to an array when a button click in iphone

空扰寡人 提交于 2019-12-11 17:45:11
问题 I have a text field In that user can enter values from 1-10 at the bottom of the text field i have button. i need to add the values in text filed to array when user clicks done button for this i wrote code like this. - (void)viewDidLoad { [super viewDidLoad]; PainlevelsArray = [[NSMutableArray alloc] init]; //PainlevelsArray declared in .h } -(IBAction)doneClick:(id)sender { [PainlevelsArray addObject:txtField.text ]; // [PainlevelsArray insertObject:rateLabel.text atIndex:0 ]; NSLog(@

Can't remove all objects in NSMutableArray

余生长醉 提交于 2019-12-11 17:04:13
问题 For some reason, I keep getting this error when I run my app: [__NSArrayI removeAllObjects]: unrecognized selector sent to instance I set up the NSMutableArray in .m like this: @implementation ChooseViewController { NSMutableArray *trackName; } And populate it like this: trackName = [JSON valueForKeyPath:@"results.trackName"]; But when I run this code, it gives me the error: [trackName removeAllObjects]; Everything else works fine and the data in trackName works. It's just messing up when I

NSArray issue in segmentedcontrol

落爺英雄遲暮 提交于 2019-12-11 16:36:37
问题 I used this example to create a segmented view. In my viewDidLoad method I am getting a warning and code crashes. - (void)viewDidLoad { [super viewDidLoad]; self.segmentedViewControllers = [self segmentedViewControllerContent]; NSArray * segmentTitles = [self.segmentedViewControllers arrayByPerformingSelector:@selector(title)]; self.segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTitles]; self.segmentedControl.selectedSegmentIndex = 0; self.segmentedControl

Always trigger a notification by matching the current time to that in array in objective c ios

爱⌒轻易说出口 提交于 2019-12-11 15:50:11
问题 Hello guys I am new to objective c, I am trying to trigger a notification when the current time matches the time of an array named newarr i have added times in this array. I want the notifications should be triggered automatically based on the times added in array. Now I have made an if statement whenever the current time matches the time given an array the notification is being triggered. but the ap is working fine but the only one notification is being triggered. please help me to trigger

OC 数组以及字符串拼接与分割

你说的曾经没有我的故事 提交于 2019-12-11 15:32:55
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 1.OC的数组成员是任意的对象指针 与C中的链表结构类似(以nil结尾) 一切的数组操作不能 越界 OC的数组分为不可变数组 NSArray 可变数组 NSMutableArray NSArray * array = [[NSArray alloc]initWithObjects:@"one",@"two",@"three", nil]; NSLog(@"%@",[array objectAtIndex:0]);//通过下标获取数组成员(下标从0开始) NSLog(@"%ld",[array count]);//获取数组有效成员个数 (不包括nil) for (i = 0; i < [array count]; i++) {//遍历数组(C方法) NSLog(@"%@",[array objectAtIndex:i]); } NSLog(@"%@",array);//(OC)查看数组内容(先给array发送description消息,然后给每个成员都发送一个description消息) NSArray * array1 = [[NSArray alloc]initWithArray:array];//创建数组对象 相当于拷贝 NSArray * arry2 = [NSArray arrayWithArray