• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How call upper layer function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How call upper layer function


  • Subject: Re: How call upper layer function
  • From: Rodrigo Zanatta Silva <email@hidden>
  • Date: Tue, 19 Apr 2011 17:50:26 -0300

Lol, sorry for making your life hard :P

let's write better. (Will be a problem in your computer with this font in
e-mail? )

//This is LevelUp.h
#import "LeveDown.h"
@interface LevelUp : NSObject  {
}
-(void) init;
-(void)wantCallThisFunction
@end

//This is LevelUp.m
@implement LevelUp
-(void) init {
    LevelDown *test = [[LevelDown alloc] init];
}

-(void)wantCallThisFunction {
///Do something
}
@end

//////////////////////////////
//  levelDown.h
@interface LevelDown : UIView { //Some class
-(void) init;
-(void)keyboardWillShow;
}
@end

//LevelDown.m
@implement
-(void) init {};
-(void)keyboardWillShow {
//iOS automatic call this function
//I need to call wantCallThisFunction
}

Like I say, if I use this line in keyboardWillShow function :
[[NSNotificationCenter defaultCenter] postNotificationName:@"thisWork"
object:nil];

And to catch this call, in function init of LevelUp class , I have to use
this line
 [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(wantCallThisFunction)
name:@"thisWork" object:nil];

So the question is: there are another way to do that?

Now I am thinking that I have to remake the program and use a third object
that create instances of LevelUp and LevelDown in the same object. Am I
correct, or there are another way? I'm not remembering if java have problem
like that.


2011/4/19 Conrad Shultz <email@hidden>

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 4/19/11 1:07 PM, Rodrigo Zanatta Silva wrote:
> > I think this is simple, but i am have no idea. I create a upper class:
> >
> > #import "downClass.h"
> > @interface MyUpperClass : NSObject
> >
> > and in than I create
> >
> > downClass *test = [[downClass alloc] init].
> >
> >
> > Than in my downClass is just a think like
> > @interface downClass: NSObject
> >
> > They are not Inheritance, so [super function] don't work. My problem is I
> > want to call a function in MyUpperClass and I am in downClass. It's a
> > instance function (like "- (void) function", not with +) so [MyUpperClass
> > function] will not work.
> >
> > The solution was use
> > [[NSNotificationCenter defaultCenter] addObserver:self
> > selector:@selector(function:)
> > name:@"observer" object:nil];
> > to listen and
> > [[NSNotificationCenter defaultCenter] postNotificationName:@"observer"
> > object:nil];
> > to call.
> >
> > Do this a correct way to do? There are another way better than this? For
> me,
> > this way cause problem because it's a little GOTO style and in debug make
> > things difficult.
>
> I'm having a very hard time following what you are trying to do, in part
> because generic names in code (e.g. "upperClass" and "function") are
> hard to keep straight.
>
> You say you are trying to call an instance method.  Do you mean you just
> want to do something like:
>
> MyUpperClass *upperClass = [[MyUpperClass alloc] init];
> [upperClass function:someVariable];
>
> ??
>
> - --
> Conrad Shultz
>
> Synthetiq Solutions
> www.synthetiqsolutions.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iD8DBQFNre4WaOlrz5+0JdURApttAKCKIifHWsYZNAPkjb6kxhwoHY5JBACggSPh
> OmZ/cESJXSqxfpgLi5j+gtY=
> =ZLvW
> -----END PGP SIGNATURE-----
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How call upper layer function
      • From: Conrad Shultz <email@hidden>
    • Re: How call upper layer function
      • From: Michael Dautermann <email@hidden>
References: 
 >How call upper layer function (From: Rodrigo Zanatta Silva <email@hidden>)
 >Re: How call upper layer function (From: Conrad Shultz <email@hidden>)

  • Prev by Date: Re: Find network mounted DVD's
  • Next by Date: NSArrayController & image in column
  • Previous by thread: Re: How call upper layer function
  • Next by thread: Re: How call upper layer function
  • Index(es):
    • Date
    • Thread