iPhone的异步图像加载
我试图让异步图像加载在我的应用程序中工作,但显然我真的很差劲,即使是在复制代码的时候!我一直在学习本教程: 我的.h文件中有3个错误。我的整个.h文件自上而下如下所示:iPhone的异步图像加载,iphone,xcode,asynchronous,Iphone,Xcode,Asynchronous,我试图让异步图像加载在我的应用程序中工作,但显然我真的很差劲,即使是在复制代码的时候!我一直在学习本教程: 我的.h文件中有3个错误。我的整个.h文件自上而下如下所示: // // GGImageLoader.h // // // Copyright 2011 __MyCompanyName__. All rights reserved. // #import <UIKit/UIKit.h> @protocol GGImageLoader // Asynchrono
//
// GGImageLoader.h
//
//
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol GGImageLoader
// Asynchronous Image loading
@interface GGImageLoader : NSObject { // ERROR - "No type or storage class may be specified here before 'interface'"
NSURLConnection * connection;
NSURL * url;
NSMutableData * mutData;
UIImage * image;
id delegate;
}
@property ( nonatomic, retain ) UIImage * image;
- (id)initWithURL:(NSURL *)aURL;
- (void)setDelegate:(id)anObject;
- (void)load;
@end
@protocol GGImageLoaderProtocol // ERROR - "No type or storage class may be specified here before 'interface'"
@required
- (void)imageLoader:(GGImageLoader *)loader
didLoadImage:(UIImage *)anImage;
@optional
- (void)imageLoader:(GGImageLoader *)loader
didReceiveError:(NSError *)anError;
@end
//
//
//GGImageLoader.h
//
//
//版权所有2011年uu MyCompanyName uuu。版权所有。
//
#进口
@协议图像加载器
//异步图像加载
@接口GGImageLoader:NSObject{//ERROR-“此处不能在“接口”之前指定任何类型或存储类”
NSURLConnection*连接;
NSURL*url;
NSMutableData*mutData;
UIImage*图像;
id代表;
}
@属性(非原子,保留)UIImage*image;
-(id)initWithURL:(NSURL*)aURL;
-(void)setDelegate:(id)一个对象;
-(空)荷载;
@结束
@协议GGImageLoaderProtocol//ERROR-“此处不能在“接口”之前指定任何类型或存储类”
@必需的
-(void)图像加载器:(GGImageLoader*)加载器
didLoadImage:(UIImage*)动画;
@可选的
-(void)图像加载器:(GGImageLoader*)加载器
didReceiveError:(n错误*)一个错误;
@结束
//
我得到的错误写在上面代码的旁边,第三个是“方法声明不在@interface上下文中”
非常感谢您的建议。页面顶部的
@protocol GGImageLoader
是什么。删除它。您需要放入在@protocol GGImageLoader
之后的两个位置添加@end
在@protocol GGImageLoader
之后,您提供的链接上也没有任何此类内容的参考。只应定义一个协议,该协议在最后正确执行。不导致错误是什么意思。据我所知,协议中没有接口的概念。谢谢你的回复。当我创建GGImageLoader.h@protocol时,GGImageLoader
已经在那里了。如果我删除它,我会得到32个错误。因此,当您创建一个新文件时,您在Xcode中将其指定为协议“.h”文件。没关系,根本不需要这个协议定义。接下来的一个问题是,你是否有“GGImageLoader.m”并且包含了这个“.h”头文件?@robin-我在xcode中找不到flip view应用程序。你能给我指一些有这个代码的网页链接吗。苹果确实在网上列出了所有示例代码。另外,我们可以将此对话转移到某个SO聊天室吗。我不想为我们的讨论劫持这条线索