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

PewPew

macrumors newbie
Original poster
Oct 28, 2010
2
0
Hi,
I'm making an alarm-app and I came across a problem;
My equals code:
Code:
	if(afLabel.text == afLabel2.text)
	{
		afLabel.text = @"!!!!!";
	}
	else{
		afLabel.text = clockLabel.text;
		afLabel2.text = testAlarm2.text;
}

Whats in clockLabel:
Code:
[formatter setDateFormat:@"hh:mm a"];
[clockLabel setText:[formatter stringFromDate:date]];

testAlarm2:
Code:
[testAlarm setText:[pickAlarm.date descriptionWithCalendarFormat:@"%I:%M %p" timeZone:nil locale:nil]];

I did that so that the time both will be displayed as ex. 08:15 AM, but it just doesn't seem to work even though they have the exact same text in them:
(The upper one is afLabel and the lower one is afLabel2)
32zl7np.png


I know this way probably isn't a good way, but I'm new so, yeah.. :rolleyes:
Thanks in advance!:D
 
Code:
if(afLabel.text == afLabel2.text)
^^This isn't the correct way to compare the string values. You're comparing pointers.

The correct way is using NSString's isEqualToString: method:
Code:
if ([afLabel.text isEqualToString: afLabel2.text])
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.