-2
-(id)initWithUserSettings:(id)userSettings mqttSender:(id)sender;

    NSDictionary *settings3=[[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/myfilehere.plist"];

        if ([[settings3 objectForKey:@"invisiblechat"] boolValue]){

        return NULL;

        }

        else{%orig;}

    [settings3 release];

    }

I don't know if this code is the right one, I am searching 2 days without an answer. On -(void) this code works really good and it keeps the -(void) disabled until the objecForKey is disabled. What I want is to keep the (id)mqttSender disabled/enabled with the toggle, I can't do it though. Any help please?

1 Answers1

0

Im not quite sure what you are trying to achieve from your explanation but if your going to init a class that is a subclass of NSObject you need to be at least call [super init] and return self, if you dont whatever is calling the init method will fail to get a reference to that object.

Setting a return value of 'void' means that the method shouldn't return anything, if you set 'id', then 'id' is a representative of a value that you haven't defined so it can be nearly anything.

With your method you are setting a return value of 'id' which means you should be returning something from that method. At the moment you have a single return inside of your 'if' statement, but after that your method is open ended and doesn't return anything. Xcode will throw up a compile error in this case because you are failing to return anything and it's expecting at least something to come out of the method, even if it's nil.

One other thing: you only end a method deceleration with a semi-colon when defining a method/function, when you implement the method/function you don't need a semi-colon as you are following it with curly braces which contain your code for that method/function.

dlbuckley
  • 685
  • 1
  • 5
  • 14
  • I am compiling this as a tweak on theos. The code above is missing a { by mistake and some others, copied wrong. Anyways, is there a way to set a return on mqttSender? Its the only thing I want to be done, everything else I want to run originally (%orig) – user2187400 Mar 19 '13 at 21:21