Re: popup menu code
Re: popup menu code
- Subject: Re: popup menu code
- From: Greg Titus <email@hidden>
- Date: Tue, 23 Jul 2002 13:11:44 -0700
Hi Luke,
From the error messages you are getting, it looks to me like the
compiler thinks that this part of your code isn't inside a method or
function at all. I'd have to see more of what is above the excerpt you
posted here to be sure. A common cause of errors like that is accidently
using one too many close-curly-braces farther up in the file. Something
like:
while (foo)
bar;
}
(Note closing brace without opening brace.) This kind of thing ends the
method you are in, and the code after it starts getting 'illegal
external declaration's.
Also, as a style issue, you should probably be setting tags on your
popup items, using [[searchPopup selectedCell] tag], and comparing based
on tag. This will (a) be slightly more efficient than comparing strings,
but more importantly (b) allow your application to be localized into
other languages by simply modifying the nib, instead of requiring code
changes. Having titles as constants in your code as well as appearing in
the user interface is a recipe for unlocalizability. You may not be
planning on shipping your application with multiple languages right now,
but it is a good habit to get into.
Hope this helps,
-Greg
On Monday, July 23, 2001, at 01:33 PM, Luke Sands wrote:
Hi everyone,
What is wrong with this popup menu code or is there a better way to do
it? I get the following errors repeated:
illegal expression, found "unknown"
illegal external declaration, missing ';' after 'isEqualTostring'
Code:
NSString *tmpTitle;
NSString *tmpURL;
tmpTitle =[searchPopup titleOfSelectedItem];
if ([tmpTitle isEqualToString:@"Google" ])
{
NSLog(@"Google Selected");
tmpURL = @"http://www.google.com/search?q=";
}
if ([tmpTitle isEqualToString:@"Apple Developers Site" ])
{
NSLog(@"Apple Selected");
tmpURL = @"http://developer.apple.com/cgi-
bin/search.pl?q=";
}
if ([tmpTitle isEqualToString:@"Cocoa-Dev List" ])
{
NSLog(@"Cocoa-Dev Selected");
tmpURL =
@"http://cocoa.mamasam.com/search/results.php?words=";
}
Luke
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.