• 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
Pb implementing shared instance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pb implementing shared instance


  • Subject: Pb implementing shared instance
  • From: "Kubernan @ 10191 Technologies" <email@hidden>
  • Date: Sat, 20 Nov 2004 15:18:37 +0100

Hello,

After reading the archive mailing list (and some web pages) i'm still not able
to implement a shared instance (!).
I have a compilation warning and i don't understand why :

compiling classB.m
" classA may not respond to '-sharedInstance' "


What i need is to establish a reference of class A in class B.
If you have an idea ...

Here's my code :

file classA.h
@interface classA : NSObject {

// other...
}
+(classA *)sharedInstance;
// other ..
@end


file classA.m
#import classA.h

@implementation classA
static classA *_sharedInstance = nil;
+(classA *)sharedInstance
{
static classA *_sharedInstance = nil;
if (_sharedInstance == nil)
_sharedInstance = [[self alloc) init];
return _sharedInstance;
}
@end


I use the shareInstance here :
file classB.h
#import classA.h
@interface classB : NSObject {
classA *classARef;
// other...
}

-(void)setAReferanceToClassA:(classA *)aData;

file classB.m
#import "classB.h"
@implementation classB
-(void)setAReferanceToClassA:(classA *)aData
{
classARef = [aData sharedInstance]; // <-- THE COMPIL WARNING (!?)
}
@end

Thanks a lot,
K.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Pb implementing shared instance
      • From: Robbie Haertel <email@hidden>
  • Prev by Date: Not Sure of Memory Leak with ** ?
  • Next by Date: Re: Not Sure of Memory Leak with ** ?
  • Previous by thread: Re: Not Sure of Memory Leak with ** ?
  • Next by thread: Re: Pb implementing shared instance
  • Index(es):
    • Date
    • Thread