Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
Hi,
I have 2 .NIB files and each of them have 2 .h and .m files
I called a function I wrote on the first .m file from the second .m file,
the method saying that every time the function get called,the lable.text is
bla bla.
but when I'm calling the function it's skipping the line that says
Code:
mylable.text=@"bla bla";

why is it skipping the above line?

Thanks
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
It's probably not skipping that line (unless, of course, you have it inside some kind of conditional logic). You're probably just not getting the intended effect. So, first, have you tried setting a breakpoint near that line to confirm that is is being skipped?

P.S. It will probably help if you included the code for the entire method from the first class that you are calling from the second class, as well as the .h for the first class. Then you should also include the code from the second class that calls this method from the first class, as well as the code you use to instantiate an object of the first class from within the second. Please be a specific as possible. Then we can avoid using phrasing like "first class" and instead use something like FirstClassName.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
Hi,
but when I'm calling the function it's skipping the line that says
Code:
mylable.text=@"bla bla";

why is it skipping the above line?

How do you know it's skipping the line? Are you basing this conclusion on the observation that the label's text doesn't change? If so, then such an observation could also be explained by either of the following:
A. mylable is nil.
B. mylable isn't displayed.


Always provide the following:
1. Describe what you expected to happen.
2. Describe what actually happened.

You have described neither what you expected, nor what actually happened. What you have done is give your conclusion based on something you did or saw, but you haven't described what you did or saw.
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
How do you know it's skipping the line? Are you basing this conclusion on the observation that the label's text doesn't change? If so, then such an observation could also be explained by either of the following:
A. mylable is nil.
B. mylable isn't displayed.


Always provide the following:
1. Describe what you expected to happen.
2. Describe what actually happened.

You have described neither what you expected, nor what actually happened. What you have done is give your conclusion based on something you did or saw, but you haven't described what you did or saw.

I put
Code:
NSLog(@"ViewAppear");
below the method title and below the line that the method is skipping and on the debugger console screen it wrote "ViewAppear" twice.

The FirstViewClass:
Code:
#import "TapView.h"
@implementation Select

- (void)viewDidLoad {
    [super viewDidLoad];
	TapMet = [[TapView alloc] init]; // I wrote "TapView *TapMet" at the .h file 
}

-(void)viewWillDisappear:(BOOL)animated {
	[TapMet LableText];

@end
}

The SecondViewClass:
Code:
@implementation TapView

-(void)LableText {
        NSLog(@"ViewAppear1");
	FlagNU++;
	NSString * NSScore=[NSString stringWithFormat:@"%i",FlagNU];
	flagLabel.text=NSScore;
        ViewAppear(@"ViewAppear2");
}

@end
}
 
Last edited:

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
First, what other debugging have you done within the LableText method? Have you checked that FlagNU is being incremented correctly? Have you checked that NSScore is being set as hoped? Have you confirmed that flagLabel is not nil? Etc.

Second, what the heck is ViewAppear(@"ViewAppear2"); ? Does that even compile? Seems you might not even be copying the actual code from your project to show to us. Please do.

Third, normal coding convention is that variables and methods begin with lower-case and class names begin with upper-case. Mixing the two can cause confusion to readers of your code. So, I would suggest: TapMet => tapMet, LableText => lableText, FlagNU => flagNU, NSScore => score (the NS prefix is unnecessary and makes one think it's referencing a Foundation class; it's not).
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
First, what other debugging have you done within the LableText method? Have you checked that FlagNU is being incremented correctly? Have you checked that NSScore is being set as hoped? Have you confirmed that flagLabel is not nil? Etc.

Second, what the heck is ViewAppear(@"ViewAppear2"); ? Does that even compile? Seems you might not even be copying the actual code from your project to show to us. Please do.

Third, normal coding convention is that variables and methods begin with lower-case and class names begin with upper-case. Mixing the two can cause confusion to readers of your code. So, I would suggest: TapMet => tapMet, LableText => lableText, FlagNU => flagNU, NSScore => score (the NS prefix is unnecessary and makes one think it's referencing a Foundation class; it's not).

It's spouse to be NSLog(@"ViewAppear2");,my mistake.
How do I check that the label is not nil?
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
Problem solved by my way :D:D:D:D

I linked the UIImageView from the 1st view to the 2nd view and it solved everything

Thanks a lot!!
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
You should've taken this as an opportunity to learn some debugging. If you want to avoid that now, well, I guess we'll see you later. :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.