iOS/Obj-C - 没有计时器的Fire本地通知?

Bri*_*any 5 objective-c ios

我想在我的iOS应用程序中设置一些本地通知,但是我似乎在实现它们时发现的每个教程似乎只允许我根据计时器发出通知(参见下面的示例代码)?是否可以在将新数据加载到UITableView时触发本地通知?很抱歉一般的问题,但我似乎无法找到很多关于此的文档.如果我的用户点击屏幕时只抓取数据,我也不确定如何才能做到这一点?例如,在ViewController的viewDidLoad中抓取/更新数据?

-(void)viewDidLoad {

        UILocalNotification *localNotification = [[UILocalNotification alloc] init];
        localNotification.fireDate = dateTime;
        localNotification.alertBody = [NSString stringWithFormat:@"Alert Fired at %@", dateTime];
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        localNotification.applicationIconBadgeNumber = 1;
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

    }
Run Code Online (Sandbox Code Playgroud)

jok*_*man 1

您可以使用下面的方法[1]代替:

- (void)postNotificationName:(NSNotificationName)aName 
                      object:(id)anObject 
                    userInfo:(NSDictionary *)aUserInfo;
Run Code Online (Sandbox Code Playgroud)

[1] https://developer.apple.com/reference/foundation/nsnotificationcenter/1410608-postnotificationname?language=objc