- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
当我如下声明 appDelegate
接口(interface)以设置 NSXMLParserDelegate
时,我从其他使用 [[UIApplication sharedApplication] delegate] 的 View 收到一些警告;
@interface AppDelegate : UIResponder <UIApplicationDelegate, NSXMLParserDelegate>
warning: Initializing 'AppDelegate *__strong' with an expression of incompatible type 'id'
但是,如果我删除它,由于 xmlParser 的 self 设置会出现另一个警告,
@interface AppDelegate : UIResponder <UIApplicationDelegate>
warning: Sending 'AppDelegate *const __strong' to parameter of incompatible type 'id'
上
xmlParser = [[NSXMLParser alloc] initWithData:receivedData];
[xmlParser setDelegate:self];
如何删除两者?谢谢
最佳答案
你真的不应该让你的 AppDelegate 公开暴露接口(interface)。它在所有代码之间创建了非常紧密的耦合。如果其他代码(在您的 AppDelegate 之外)需要 NSXMLParserDelegate,您应该为它创建一个不同的类。
看起来您的 AppDelegate 需要成为其自身目的的委托(delegate)。您可以通过在 AppDelegate.m 文件中进行类扩展来“私下”实现接口(interface)。
@interface AppDelegate() <NSXMLParserDelegate>
@end
执行上述操作将删除您在此处收到的警告:
[xmlParser setDelegate:self];
关于iphone - Xcode "AppDelegate *const __strong' 到不兼容类型的参数”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11147239/
对 Objective-C 很陌生,无法弄清楚我错过了什么。 .h文件 #import #import "RESTResponse.h" typedef void (^Callback)(RESTR
从 xcode 5.0 移动到 5.1 时,GPUImage 库出现以下错误。在谷歌上搜索后,我发现我需要像这样发送 int [NSNumber numberWithInt:number] 但问题是我
有一个方法: - (void)doSmth:(NSString *__strong*)str { NSLog(@"%@", *str); } 当 __strong 跟在方法参数的类之后是什么意
我看到有人用下面的 __strong static foo *_foo = nil; 我想知道这里是否需要__strong;我的意思是 __strong 是默认值?是吗? 最佳答案 因为强引用是 de
我有这段代码,我想做的是让 self 在将在主线程上执行的 block 中保持事件状态。结果有点随机,有时会打印 null。 - (void)viewDidLoad { [super view
该项目未启用 ARC,但我们(错误地)使用符合 ARC 的代码库 - 特别是一个用于创建 GCDSingleton.h 中定义的单例对象的代码库: #define DEFINE_SHARED_INST
当我做类似下面的事情时,我得到一个错误提示 for (UIView* att in bottomAttachments) { if (i <= [cells count]) {
所以说我对核心数据很菜鸟。我有两个 NSManagedObjects,Map 和 AddressAnnotation。在我的一个 ViewController 中,我这样做: Map *aMap =
这就是返回错误的原因: NSMutableArray *newArray = [[[NSMutableArray alloc] initWithArray:[NSJSONSerialization J
在 Objective-C 中,我们将值转换为 __weak 以避免在某些情况下发生循环引用。 This post解释了为什么 __strong 很有用 __weak typeof (self) we
我检查了几个建议的链接,但没有找到答案。我想将两个浮点值传递给对象 breuk 的初始化。该对象有一个初始化方法initwithTeller: (float) mijnTeller 和Noemer:
我在这里阅读了有关 __strong 引用和 __weak 引用的用法:Explanation of strong and weak storage in iOS5 我试着写了一些代码来展示这些知识。
在 objective-C 中,为什么我们不能 alloc+init 或 new 具有父类(super class)的基类对象,而我们可以使用父类(super class)的构造函数来初始化吗? 下面
考虑这段代码: @implementation MyClass -(void)dealloc { NSLog(@"MyClass dealloc: %@", self); } @end @im
当我的 Xcode 项目使用 .mm 文件编译时出现多个错误并且所有错误都是相同的=无。当我将 C++ 代码放入 .mm 时出现错误时,还包含一些 .cpp 文件和 .mm 没有出现问题。我们都知道如
有圆弧 测试1: @interface test01ViewController () @property (strong) void(^myBlock)(id obj, NSUInteger idx
我正在使用以下方式对我的 NSSet 进行排序: NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"name
当我如下声明 appDelegate 接口(interface)以设置 NSXMLParserDelegate 时,我从其他使用 [[UIApplication sharedApplication]
在阅读 Foundation 的标题时,我发现了这一点: - (__strong const char *)UTF8String NS_RETURNS_INNER_POINTER; // Conv
在写我最初的问题时,我无意中解决了我的问题。我想了解为什么我的更改会导致修复。 我写了一个接受 NSString 的类方法和 NSError ** .该方法返回YES如果该字符串是我的应用程序中的有效
我是一名优秀的程序员,十分优秀!