Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Implementing Designs for iPhone Finishing the User Interface Adding a Pull-to-Refresh Control

Adding a pull-toRefresh 4 of 4

The task is: Finally, at the end of 'refreshBlogPosts', end the refresh control using the appropriate method. I write in the end of the function: if([self.refreshControl isRefreshing]){ [self.refreshControl endRefreshing]; } Error is: instance method '-isRefreshing' not found (return type defaults to 'id') if([self.refreshControl isRefreshing])

"isRefreshing is underlined.

What is wrong in the code, it seems to me that this task implies just copy-pasting from the video, no?

4 Answers

Your code should look like this:

  • (void)refreshBlogPosts { // ... retrieval code omitted for brevity ... [self.refreshControl endRefreshing] }

Following will do.

- (void)refreshBlogPosts {
    // ... retrieval code omitted for brevity ...
    [self.refreshControl endRefreshing];

I'd double check to make sure you have included all of the code in the video. Make sure you have the self.refreshControl = [[UIRefreshControl alloc] init]; in the viewDidLoad. I can't seem to recreate your error. Could maybe try what these guys suggest on stackoverflow. http://stackoverflow.com/questions/5293129/how-do-i-fix-this-warning-method-not-found-return-type-defaults-to-id

I'm having the same problem. I used the following code in the implementation file:

#import "MasterViewController.h"

@implementation MasterViewController

- (void)viewDidLoad {
    [super viewDidLoad];

self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refreshBlogPosts) forControlEvents:UIControlEventValueChanged];
}

- (void)refreshBlogPosts {
    // ... retrieval code omitted for brevity ...
if ([self.refreshControl isRefreshing]) {
            [self.refreshControl endRefreshing];}
}

@end

I'm getting the following error in the "preview":

instance method '-isRefreshing' not found (return type defaults to 'id')
if ([self.refreshControl isRefreshing]) {
                         ^~~~~~~~~~~~
note: receiver is instance of class declared here
@interface UIRefreshControl : NSObject
           ^
1 error generated.

Aside from sloppy indentation, can anyone clarify what I/we're doing wrong? If it's a matter of the return type not being a pointer or defining "isRefreshing" in the header (as suggested in stackoverflow reference) seems a bit off considering the error confirms that "UIRefreshControl.h" is being referenced? Then again, I barely know what I'm talking about. Any/all clarification is welcome.

Thanks!