Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9066377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:43:05+00:00 2026-06-16T16:43:05+00:00

I’ve created a custom class with various methods in objective-c and I’ve also added

  • 0

I’ve created a custom class with various methods in objective-c and I’ve also added delegate methods to that class that can be called from another class that imports my custom class. In particular I’m working with iOS. Here’s a small sample of both my header (.h) and implementation (.m) files:

//iCloud.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@protocol iCloudDelegate;
@class iCloud;

@interface iCloud : NSObject {
    __weak id<iCloudDelegate> delegate_;
}

@property (nonatomic, weak) id <iCloudDelegate> delegate;

//Methods (abridged for StackOverflow)
+ (void)checkCloudAvailability;

@end

@class iCloud;
@protocol iCloudDelegate <NSObject>
//Methods (abridged for StackOverflow)
@optional
- (void)documentWasSaved;
@required
- (void)iCloudAvailable:(BOOL)status;
@end

And part of my implementation (.m):

#import "iCloud.h"
@implementation iCloud
@synthesize delegate;

- (void)documentWasSaved {
    [[self delegate] documentWasSaved];
}

-(void)iCloudAvailable:(BOOL)status {
    [[self delegate] iCloudAvailable:status];
}

+ (void)checkCloudAvailability {
NSLog(@"Checking iCloud availablity...");
NSURL *returnedURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];

if (returnedURL){
    NSLog(@"iCloud is available");
} else {
    NSLog(@"iCloud not available. ☹");
}
}

I’ve looked through numerous tutorials, SO postings, sample code, and more to try to figure out how to tell the delegate WHEN to call the delegate methods, but I haven’t been able to find anything. Most postings show that the implementation should add the delegate (using the <DelegateName> syntax), however my custom class implementation is not where I want to use the delegate (it’s in another class where the delegate is NOT being created in).

As you can see in the sample code above, I’ve added the delegate methods (in the implementation) but as far as I’m aware all this will do is call the delegate methods in the other classes that use it. If this is correct, then how do I get the delegate to call those methods (say from my checkCloudAvailability class which is not one of the delegate methods)? Here’s an example of what I’m trying to do:

+ (void)checkCloudAvailability
    if (returnedURL){
      [[self delegate] iCloudAvailable:YES]; 
    ...
}

When I try to use the [[self delegate] methodName]; line I get the following error, and Xcode pretends like it doesn’t know what I’m talking about anymore: enter image description here

Why is this happening? Why can’t I tell the delegate when to call the delegate methods? This works fine inside of the delegate methods, but why not in the class in which it is being implemented?

Thoughts, ideas, links, tutorials, code, or help of any kind will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:43:06+00:00Added an answer on June 16, 2026 at 4:43 pm

    The error says that it cannot find a method delegate is not available in the context of a class method (i.e. one denoted with a + sign). This may look confusing, because self inside a class method does not correspond to an instance, but to a class; the property delegate, on the other hand, belongs to an instance, meaning that it is not available.

    To address this, you should either make checkCloudAvailability an instance method, or rewrite it as follows:

    +(void)checkCloudAvailabilityWithDelegate:(id<iCloudDelegate>)delegate {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am confused How to use looping for Json response Array in another Array.
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.