0

I got three view controllers, A, B and C.
A --modal--> B ---push --> C

How can I pass data from C --> A? I have tried using protocols and delegate. However my delegate method in A is never called.

Adam Richardson
  • 2,518
  • 1
  • 27
  • 31
  • 2
    You'll have to post some code or no one will be able to help you. – jszumski Jul 16 '13 at 15:43
  • @jszumski: I dont have any code yet. My question is a theoretical one. How can A know about data that is created in C, if A did not instantiate view controller C? – pangelovski Jul 16 '13 at 17:17
  • See my answer about using NSNotificationCenter below. Check the links for details to make sure that it will accomplish what you need done. – CaptJak Jul 16 '13 at 18:15

3 Answers3

0

You could possibly do this by using NSNotificationCenter see this post where I had a similar problem. The question might not fully apply, but the answer holds a possible solution for you. Also read up here for more data.

Community
  • 1
  • 1
CaptJak
  • 3,592
  • 1
  • 29
  • 50
0

Or you can use your AppDelegate to hold a reference for A, and than work from there on.

Blitz
  • 5,521
  • 3
  • 35
  • 53
0

You can store data in session (Create singleton object) and access it whatever you wish

@interface Session : NSObject

+(Session*) session;

@property (nonatomic) id data_to_access;

@end

@implementation Session
+(Session *)session
{
    static Session *sharedSingleton;

    @synchronized(self)
    {
        if (!sharedSingleton)
            sharedSingleton = [[Session alloc] init];

        return sharedSingleton;
    }
}
@end
HotJard
  • 4,598
  • 2
  • 36
  • 36