显示来自核心数据的不同时间不同消息的警报。我试过这段代码 显示警报2秒3秒,4秒等...
if (fetchedObjectsData.count > 0) {
NSLog(@"Return data Count is ====== %lu",(unsigned long)[fetchedObjectsData count]);
for (int i=0; i <[fetchedObjectsData count] ; i++)
{
NSManagedObject *firstManagedObject = (NSManagedObject *)[fetchedObjectsData objectAtIndex:i];
NSString * distance = [firstManagedObject valueForKey:@"distance"];
NSString * typeAlert = [firstManagedObject valueForKey:@"type"];
NSString * displayTime = [firstManagedObject valueForKey:@"display_time"];
NSString * content = [firstManagedObject valueForKey:@"content"];
NSString * title = [firstManagedObject valueForKey:@"title"];
NSLog(@"How much time you here === %d",i);
if ([distance intValue]>=0 && [distance intValue]<5)
{
if ([typeAlert isEqualToString:@"1"]&& [displayTime isEqualToString:@"0"])
{
NSLog(@"typeAlert 1 0 === %d",i);
}
if ([typeAlert isEqualToString:@"1"]&& ![displayTime isEqualToString:@"0"])
{
NSLog(@"typeAlert 1 1 === %d",i);
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, [displayTime intValue] * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:title
message:content
preferredStyle:UIAlertControllerStyleAlert];
[self.window.rootViewController presentViewController:alertController animated:YES completion:nil];
});
}}}
}else {
NSLog(@"there's no with same id. Use insert method");
}
在app delegate类上显示这些警报 标题和消息来自核心数据表
我需要一个接一个地显示警报,就像2秒警报显示之后的下一个警报一样,在3秒内停留