0

I am facing the problem in displaying the value of string of AddNotesViewController Class , in the Label of the DetailsOfPeopleViewController.

All i want to do is whatever we entered in the UITextView of 1 class,should display in the UILabel of another class.

In file AddNotesViewController.h

   UITextView *txtView;

  @property(nonatomic,retain)IBOutlet     UITextView *txtView;

in file AddNotesViewController.m

 @synthesize txtView;

After this when i click on the tab bar item "save" then it should save in the data base , its saving to database and displaying the value also but its not passing the value to

DetailsOfPeopleViewController .

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{

        NSLog(@"Tabbar selected itm %d",item.tag);

       switch (item.tag) {
          case 0:

         appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];


        NotesTable *crashNotInvolvingObj11 = (NotesTable *)[NSEntityDescription       
    insertNewObjectForEntityForName:@"NotesTable" inManagedObjectContext:[appDelegate    managedObjectContext]];

        // CameraViewController *camera=[[CameraViewController alloc] init];
            crashNotInvolvingObj11.personNote=[NSString    stringWithFormat:@"%@",txtView.text];

        DetailsOfPeopleViewController *detail=[DetailsOfPeopleViewController alloc];
        detail.testPersonNotesStr  =[NSString stringWithFormat:@"%@",txtView.text];
        //(value of testPersonNotesStr is DISPLYING here... )
        [appDelegate saveContext];
        [detail release];

        break;
        ..................

     }

in DetailsOfPeopleViewController.h

    NSString *testPersonNotesStr;
    UILabel *PersonNotesLbl;

     @property(nonatomic,retain)IBOutlet UILabel *PersonNotesLbl;
     @property(nonatomic,retain) NSString *testPersonNotesStr;

in DetailsOfPeopleViewController.m

       @synthesize PersonNotesLbl;
       @synthesize  testPersonNotesStr;



      - (void)viewDidLoad
      {
         [super viewDidLoad];
            [PersonNotesLbl setText:testPersonNotesStr];

         NSLog(@"PERSON NOTE is........ %@",testPersonNotesStr);
           //(value of testPersonNotesStr is NOT DISPLYING here..... )

        }

Please guide me where am I doing the mistake.

Rajneesh071
  • 30,846
  • 15
  • 61
  • 74
suvarna
  • 697
  • 2
  • 7
  • 10

3 Answers3

0

You make it a property, so possibly try using the set method. Also, you need to init your ViewControlelr before setting the value. So:

DetailsOfPeopleViewController *detail=[[DetailsOfPeopleViewController alloc] init];
[detail setTestPersonNotesStr:[NSString stringWithFormat:@"%@",txtView.text]];

And I do not see where you actually display this view, you have to be displaying the same instance of this view to actually see the value.

ophychius
  • 2,623
  • 2
  • 27
  • 49
0

use delegates to pass values use this reference

NANNAV
  • 4,875
  • 4
  • 32
  • 50
0

Just do few thing in your code you will get you string

1 :->

Declair your DetailsOfPeopleViewController globally.

i.e. in .h

DetailsOfPeopleViewController *detail  

2 :->

in your viewDidLoad alloc it in memory

detail=[[DetailsOfPeopleViewController alloc] init];  

3 :->

Just declare your string property to copy

@property(nonatomic,copy) NSString *testPersonNotesStr;  

or

You can send data using NSUserDefault

SetValue

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSString stringWithFormat:@"%@",txtView.text]; forKey:@"testPersonNotesStr"];
[defaults synchronize];

GetValue

testPersonNotesStr = [[NSUserDefaults standardUserDefaults] objectForKey:@"testPersonNotesStr"];
NSLog(@"PERSON NOTE is........ %@",testPersonNotesStr);  

Follow my answer i have NSString value in addViewController and i want to display this value in UILabel of DetailsViewController

Community
  • 1
  • 1
Rajneesh071
  • 30,846
  • 15
  • 61
  • 74
  • where is the code to push to DetailsOfPeopleViewController, mean using which code you are going yo DetailsOfPeopleViewController – Rajneesh071 Nov 28 '12 at 13:41
  • some other class is there its name is PeopleHomeViewController which containes table view , if we click on the row of the tableView then it will go for DetailsOfPeopleViewController. – suvarna Nov 28 '12 at 13:48
  • ohh....i got it yar...Thank you very much...can u explain bit about y its not displayed with the way i tried.... – suvarna Nov 28 '12 at 14:13
  • according to your way you are making object of secondView and passing value in the string, and in ThirdView(PeopleHomeViewController) you are again making object of secondView and navigate using this object...so this is completely new object...its not passing string value – Rajneesh071 Nov 28 '12 at 14:17
  • its accepted now r8?? This is first time yar i was checking where to accept the ans... – suvarna Nov 29 '12 at 05:45
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/20314/discussion-between-rajneesh071-and-suvarna) – Rajneesh071 Nov 29 '12 at 10:13