• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why won't compile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why won't compile


  • Subject: Why won't compile
  • From: Mike Abdullah <email@hidden>
  • Date: Sun, 8 Jan 2006 17:53:26 +0000

I'm trying to figure out why one earth my code won't compile. Can anyone shed some light?

NSURL *scriptURL = [NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource: @"theScript" ofType: @"scpt"]];
NSAppleScript *theScript = [[NSAppleScript alloc] initWithContentsOfURL: scriptURL error: nil];
NSAppleEventDescriptor *scriptResults = [theScript executeAndReturnError: nil];
[theScript release];

switch([[scriptResults descriptorAtIndex: 1] int32Value]) {
case 0:
// Create the document
[super newDocument: sender];
break;

case 1:
// Mail is not running
NSAlert *theAlert = [NSAlert alertWithMessageText: @"foo"
defaultButton: @"Try Again"
alternateButton: @"Cancel"
otherButton: nil
informativeTextWithFormat: @"more foo"];
if ([theAlert runModal] == NSAlertDefaultReturn) {
[self newDocument: sender];
}
else {
return;
}
break;

case 2:
// No messages are selected
NSAlert *theAlert = [NSAlert alertWithMessageText: @"foo 2"
defaultButton: @"Try Again"
alternateButton: @"Cancel"
otherButton: nil
informativeTextWithFormat: @"more foo2"];
if ([theAlert runModal] == NSAlertDefaultReturn) {
[self newDocument: sender];
}
else {
return;
}
break;
}


To explain, basically the code executes an AppleScript which returns an integer - 0,1 or 2. If that integer is 0 then some stuff is done (it's not important what!). If the integer is 1 then the app displays an alert, and if it's 2 then a slightly different alert is displayed.

However, the compiler is complaining about the line I have marked in bold. Is it something to do with the whole switch statement? I can get it to work fine outside of the switch statement, but to me this seemed the best way of organising the task.

Any ideas?

Mike A.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Why won't compile
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: OCUnit unit tests and user defaults...
  • Next by Date: Re: Why won't compile
  • Previous by thread: Re: OCUnit unit tests and user defaults...
  • Next by thread: Re: Why won't compile
  • Index(es):
    • Date
    • Thread