edhog
edhog

Reputation: 513

Asynchronous image loading for iPhone

I'm trying to get asynchronous image loading working in my app but apparently I just really suck, even when copying code! I've been following this tutorial: http://www.geekygoodness.com/2009/09/13/a-simple-cocoa-asynchronous-image-loader-class-to-use-in-your-iphone-app/

and I'm getting 3 errors in my .h file. My entire .h file from top to bottom looks like this:

//
//  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
//

The errors I get are written next to the code above, and the 3rd is "Method declaration not in @interface context".

I'd really appreciate any advice.

Upvotes: 0

Views: 2254

Answers (3)

Shamitha
Shamitha

Reputation: 1407

Add @end after @protocol GGImageLoader

Upvotes: 0

Robin
Robin

Reputation: 10011

You need to put ; after the @protocol GGImageLoader at both the places

Upvotes: 0

Ankit
Ankit

Reputation: 4710

what is @protocol GGImageLoader on top of the page. Remove that.

Upvotes: 1

Related Questions