小编Nub*_*lon的帖子

按字符串属性的第一个字母过滤数组

我有一个NSArray具有name属性的对象.

我想通过过滤数组 name

    NSString *alphabet = [agencyIndex objectAtIndex:indexPath.section];
    //---get all states beginning with the letter---
    NSPredicate *predicate =
    [NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", alphabet];
    NSMutableArray *listSimpl = [[NSMutableArray alloc] init];
    for (int i=0; i<[[Database sharedDatabase].agents count]; i++) {
        Town *_town = [[Database sharedDatabase].agents objectAtIndex:i];
        [listSimpl addObject:_town];
    }
    NSArray *states = [listSimpl filteredArrayUsingPredicate:predicate];
Run Code Online (Sandbox Code Playgroud)

但我得到一个错误 - "不能用不是字符串的东西做一个子串操作(lhs = <1,箭头> rhs = A)"

我怎样才能做到这一点?我想过滤数组中的第一个字母name为'A'.

cocoa-touch objective-c filter nsarray ios

16
推荐指数
2
解决办法
4万
查看次数

如何在缩放时计算MapView上显示的数字和注释?

当我缩放mapView时,我需要计算注释的数量,并获得在地图上显示的数组,然后,我需要重新加载我的表并显示仅在地图上显示的列表.

如何获得带注释的数字和数组?

mkmapview mkannotation ios

8
推荐指数
2
解决办法
4053
查看次数

iOS:如何在没有动画的情况下在indexPath上重新加载单元格?

我有UITableView与细胞.当我选择单元格 - 高度增加时,当我再次选择此单元格时 - 高度降低.在方法"didSelectRowAtIndexPath"我用这个 -

NSArray *indArr = [[NSArray alloc] initWithObjects:(NSIndexPath*)[timer userInfo], nil];
[self.tableView reloadRowsAtIndexPaths:indArr withRowAnimation:UITableViewRowAnimationFade];
Run Code Online (Sandbox Code Playgroud)

但是"UITableViewRowAnimationFade"动画已经褪色,并且细胞闪烁.我尝试了另一种动画,但它们也不合适(

如何避免这种影响并更新没有动画的单元格?

uitableview ios

4
推荐指数
1
解决办法
6271
查看次数

一个UITableViewCell文本标签中的两种文本颜色

我有一个UITableViewCell由两个单词组成的文本标签.

如何更改单词的颜色; 将第一个单词设为绿色,将第二个单词设为红色?

uitableview nsattributedstring ios

3
推荐指数
2
解决办法
4278
查看次数

我如何在UILocalNotification中更改UserInfo?

我有6个UILocalNotifications.每个通知都有自己的"userInfo"

  1. @ "1"
  2. @ "2"
  3. @ "3"
  4. @ "4"
  5. @ "5"
  6. @ "6"

然后我删除通知号4,并有5个通知:

  1. @ "1"
  2. @ "2"
  3. @ "3"
  4. @ "5"
  5. @ "6"

如何在通知中更改"userInfo"以获取:

  1. @ "1"
  2. @ "2"
  3. @ "3"
  4. @ "4"
  5. @ "5"

保存代码 -

// Specify custom data for the notification

NSDictionary *infoDict = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"%i", i] forKey:@"notif"];
localNotif.userInfo = infoDict;
 i = i + 1;
Run Code Online (Sandbox Code Playgroud)

德尔代码 -

if (flagTable == 1)
{
    int numberPhoto = [[[UIApplication sharedApplication] scheduledLocalNotifications] count];
    int numPhFlag = …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uilocalnotification

2
推荐指数
1
解决办法
5589
查看次数