gpt4 book ai didi

ios - 无法在 NSNotificaitonCenter 的 addObserver : selector: name: object: method 中使用 UIApplicationDidEnterBackgroundNotification 作为名称

转载 作者:可可西里 更新时间:2023-11-01 06:20:35 27 4
gpt4 key购买 nike

我将一个文件复制到一个新项目中,它似乎工作正常。这段代码也在旧项目中工作,但突然之间(在新项目中),我遇到了几个我无法弄清楚的错误。

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];

[center addObserver:self
selector:@selector(saveBookmarks)
name:UIApplicationWillTerminateNotification
object:nil];
[center addObserver:self
selector:@selector(saveBookmarks)
name:UIApplicationDidEnterBackgroundNotification
object:nil];

使用名称 UIApplicationWillTerminateNotification 给我错误“使用未声明的标识符 UIApplicationWillTerminateNotification。”

使用名称 UIApplicationDidEnterBackgroundNotification 给我错误消息“使用未声明的标识符 UIApplicationDidEnterBackgroundNotification”,并尝试将名称更改为 NSExtensionHostDidEnterBackgroundNotification, 以清除错误,但事实并非如此我需要的?!

我知道这段代码以前可以工作,但我现在想不通为什么它现在不工作了。

最佳答案

您可能只是缺少 UIKit header :

#import <UIKit/UIKit.h>

关于ios - 无法在 NSNotificaitonCenter 的 addObserver : selector: name: object: method 中使用 UIApplicationDidEnterBackgroundNotification 作为名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30992423/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com