I am passing string between two views, my values are coming properly in first but in second view its null.
Here, I am using segue and string to pass artist name from one view to other.In first view the value is coming properly ,but in second view its null.
In first view
NSArray *artistnameArray = [value valueForKey:@"artistName"];
NSString *artistnameString = [artistnameArray objectAtIndex:indexPath.row];
UILabel *artistnameLBL = (UILabel *)[cell viewWithTag:102];
artistnameLBL.text = artistnameString;
valueToPassStr =artistnameLBL.text;
NSLog(@"ARTIST NAME : %@",artistnameLBL.text);
if ([valueToPassStr isEqualToString:@""])
{
NSLog(@"myString IS empty!");
artistnameLBL.text = @"";
}
else
{
NSLog(@" IS NOT empty, it is: %@", valueToPassStr);
LyricsViewController *lycVC= [[LyricsViewController alloc] initWithNibName:@"LyricsViewController" bundle:nil];
lycVC.valueToPassStr = artistnameLBL.text;
[lycVC setStrValue:valueToPassStr];
lycVC.strValue = valueToPassStr;
NSLog(@"VALUE IS PASSED : %@",lycVC.strValue);
In Second View
[super viewDidLoad];
NSLog(@"VIEWDID LOAD CALLED");
LyricsViewController *lycVC = [[LyricsViewController alloc] init];
defaults = [NSUserDefaults standardUserDefaults];
// Do any additional setup after loading the view.
UILabel *artistnameLBL ;
[artistnameLBL setTag:105];
lycVC.strValue = strValue;
artistnameLBL.text =[NSString stringWithFormat:@"Hi! %@ ",strValue];
NSLog(@"ARTIST NAME : %@",artistnameLBL.text);