Xcode 3.x to 4.2 transition - Runs once then stuck

I am teaching myself Xcode from a good book.  However I ran into a strange thing where a code example runs once in Xcode 4.2 and after that builds clean but gets in a loop when running and never even brings up the screen I set up in XIB.  It doesn't matter if I change the code or not.  The message showing in the debugger is [Switching to process 5521 thread 0x0] - the number seems to be rather random.  The first run was clearly stopped using the menu quit command, but it is like it is trying to write over itself or something.
It finally dawned on me that perhaps this has something to do with the upgrade from Xcode 3.x to Xcode 4.2.  The book example I am following was written to Xcode 3.  The book examples had similar errors with NSDictionary and NSArray examples.
The code is pretty short, so I am including it all.  It really is beginner level.  I am sure I just need an experienced eye to point out some mis-direction on my part.  Thanks for any coaching I can get.  I only wrote the first method and added a line to the init method. 
Document.h
#import <Cocoa/Cocoa.h>
@interface Document : NSDocument
    NSMutableDictionary *mainDictionary;
    IBOutlet NSTextField *kRefInField;
    IBOutlet NSTextField *dataInField;
- (IBAction)storeRefAndData: (id)sender;
@end
Document.m
#import "Document.h"
@implementation Document
- (IBAction)storeRefAndData: (id)sender
    NSString *kRefToStore = [kRefInField stringValue];
    NSString *dataToStore = [dataInField stringValue];
    [mainDictionary setValue:dataToStore forKey:kRefToStore];
- (id)init
    self = [super init];
    if (self) {
        // Add your subclass-specific initialization here.
        // If an error occurs here, return nil.
        mainDictionary = [[NSMutableDictionary alloc] init];
    return self;
- (NSString *)windowNibName
    // Override returning the nib file name of the document
    // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
    return @"Document";
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
    [super windowControllerDidLoadNib:aController];
    // Add any code here that needs to be executed once the windowController has loaded the document's window.
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
     Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning nil.
    You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
    NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented",NSStringFromSelector(_cmd)]userInfo:nil];
    @throw exception;
    return nil;
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError**)outError
    Insert code here to read your document from the given data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning NO.
    You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
    If you override either of these, you should also override -isEntireFileLoaded to return NO if the contents are lazily loaded.
    NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented",NSStringFromSelector(_cmd)]userInfo:nil];
    @throw exception;
    return YES;
+ (BOOL)autosavesInPlace
    return YES;
@end

I am teaching myself Xcode from a good book.  However I ran into a strange thing where a code example runs once in Xcode 4.2 and after that builds clean but gets in a loop when running and never even brings up the screen I set up in XIB.  It doesn't matter if I change the code or not.  The message showing in the debugger is [Switching to process 5521 thread 0x0] - the number seems to be rather random.  The first run was clearly stopped using the menu quit command, but it is like it is trying to write over itself or something.
It finally dawned on me that perhaps this has something to do with the upgrade from Xcode 3.x to Xcode 4.2.  The book example I am following was written to Xcode 3.  The book examples had similar errors with NSDictionary and NSArray examples.
The code is pretty short, so I am including it all.  It really is beginner level.  I am sure I just need an experienced eye to point out some mis-direction on my part.  Thanks for any coaching I can get.  I only wrote the first method and added a line to the init method. 
Document.h
#import <Cocoa/Cocoa.h>
@interface Document : NSDocument
    NSMutableDictionary *mainDictionary;
    IBOutlet NSTextField *kRefInField;
    IBOutlet NSTextField *dataInField;
- (IBAction)storeRefAndData: (id)sender;
@end
Document.m
#import "Document.h"
@implementation Document
- (IBAction)storeRefAndData: (id)sender
    NSString *kRefToStore = [kRefInField stringValue];
    NSString *dataToStore = [dataInField stringValue];
    [mainDictionary setValue:dataToStore forKey:kRefToStore];
- (id)init
    self = [super init];
    if (self) {
        // Add your subclass-specific initialization here.
        // If an error occurs here, return nil.
        mainDictionary = [[NSMutableDictionary alloc] init];
    return self;
- (NSString *)windowNibName
    // Override returning the nib file name of the document
    // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
    return @"Document";
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
    [super windowControllerDidLoadNib:aController];
    // Add any code here that needs to be executed once the windowController has loaded the document's window.
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
     Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning nil.
    You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
    NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented",NSStringFromSelector(_cmd)]userInfo:nil];
    @throw exception;
    return nil;
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError**)outError
    Insert code here to read your document from the given data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning NO.
    You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
    If you override either of these, you should also override -isEntireFileLoaded to return NO if the contents are lazily loaded.
    NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented",NSStringFromSelector(_cmd)]userInfo:nil];
    @throw exception;
    return YES;
+ (BOOL)autosavesInPlace
    return YES;
@end

Similar Messages

  • Xcode 4.2 Example runs once then stuck

    I was having an issue, so I went back to a book example and found the same problem.  I am trying to create a very simple NSDictionary application under Cocoa.  At an early point I tried 'build and run' and it worked to bring up the screen I am constructing.  However, when I stop that run, and then repeat build and run, it never shows the screen.  It comes up with the following message and seems to be in a loop from there.  The number seems to be an almost random number.  I am sure it is a novice error, but it is stopping all progress!  Any help would be appreciated.
    tty /dev/ttys000
    [Switching to process 4792 thread 0x0]

    Thanks.  The code is pretty short, so I am including it all.  It really is beginner level.  I am sure I just need an experienced eye to point out some mis-direction on my part.  Thanks for any coaching I can get.  I only wrote the first method and added a line to the init method.  It has occurred to me that perhaps this has something to do with the upgrade from Xcode 3.x to Xcode 4.2.  The book example I am following was written to Xcode 3.  The book examples had similar errors with NSDictionary and NSArray examples.
    Document.h
    #import <Cocoa/Cocoa.h>
    @interface Document : NSDocument
        NSMutableDictionary *mainDictionary;
        IBOutlet NSTextField *kRefInField;
        IBOutlet NSTextField *dataInField;
    - (IBAction)storeRefAndData: (id)sender;
    @end
    Document.m
    #import "Document.h"
    @implementation Document
    - (IBAction)storeRefAndData: (id)sender
        NSString *kRefToStore = [kRefInField stringValue];
        NSString *dataToStore = [dataInField stringValue];
        [mainDictionary setValue:dataToStore forKey:kRefToStore];
    - (id)init
        self = [super init];
        if (self) {
            // Add your subclass-specific initialization here.
            // If an error occurs here, return nil.
            mainDictionary = [[NSMutableDictionary alloc] init];
        return self;
    - (NSString *)windowNibName
        // Override returning the nib file name of the document
        // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
        return @"Document";
    - (void)windowControllerDidLoadNib:(NSWindowController *)aController
        [super windowControllerDidLoadNib:aController];
        // Add any code here that needs to be executed once the windowController has loaded the document's window.
    - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
         Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning nil.
        You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
        NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented", NSStringFromSelector(_cmd)]userInfo:nil];
        @throw exception;
        return nil;
    - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
        Insert code here to read your document from the given data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning NO.
        You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
        If you override either of these, you should also override -isEntireFileLoaded to return NO if the contents are lazily loaded.
        NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented", NSStringFromSelector(_cmd)]userInfo:nil];
        @throw exception;
        return YES;
    + (BOOL)autosavesInPlace
        return YES;
    @end
    Re: [Switching to process 2576 thread 0x0] 

  • App-V 5 Application runs once then errors

    Hello Experts,
    I'm running an App-V 5.0 SP1 Management Server and Publishing Server on Server 2012 R2. My Sequencer and Client are App-V 5.0 SP2 from the current MDOP 2013 R2.
    The target systems are all running TrendMicro Antivirus, but I'm not sure, if that could be related, as the applications can run once. I'm afraid I can't uninstall or deactivate the AntiVirus in the case :-(
    I can sequence applications fine and run them once on any given system. But as soon as the application has been run once, it cannot be run on any system anymore. It errors out with the message:
    "A Problem caused the program to stop working correctly. Please close the program" then when clicking close the program, a new error message pops up: "The application was unable to start correctly (0x00000005). Click OK to close the application"
    In this case, it's FireFox, but the problem isn't related to the sequenced app - it happens to all app-v applications. If I export the sequenced app to my lab environment, the application works fine and does not through any errors.
    Here are the event viewer logs:
    Application Log:
    Faulting application name: firefox.exe, version: 27.0.1.5156, time stamp: 0x52fc0faa
    Faulting module name: MSVCR100.dll, version: 10.0.30319.1, time stamp: 0x4ba1dbbe
    Exception code: 0xc0000005
    Fault offset: 0x000407a6
    Faulting process id: 0x1668
    Faulting application start time: 0x01cf3865e9e27497
    Faulting application path: C:\Users\setup\AppData\Local\Microsoft\AppV\Client\Integration\C36655B9-CE43-445D-91CE-CCCCD2D8ABD1\Root\VFS\ProgramFilesX86\Mozilla Firefox\firefox.exe
    Faulting module path: C:\Users\setup\AppData\Local\Microsoft\AppV\Client\Integration\C36655B9-CE43-445D-91CE-CCCCD2D8ABD1\Root\VFS\ProgramFilesX86\Mozilla Firefox\MSVCR100.dll
    Report Id: 284ea35b-a459-11e3-955e-001dd8b71c30
    App-V Admin Log:
    Error encountered while executing command Mount-AppvClientPackage -PackageId abf22cdc-27ea-4d63-a937-d3824ce71196 -VersionId 9d3c1bfb-5ecc-4aa0-be9a-0f2811f5ae1a. Error: Application Virtualization Service failed to complete requested operation.
    Operation attempted: Mount Package.
    Windows Error: 0x80004004 -
    Error module: Streaming Manager. Internal error detail: 74F0282C80004004.
    Please consult AppV Client Event Log for more details.
    A virtual application could not be launched from package '' because the App-V Client Service is not running. Start the App-V Client Service and try again.
    Any Ideas? 
    Cheers,
    Fred

    Hello,
    Have you tried this hotfix?
    http://blogs.technet.com/b/appv/archive/2014/03/03/hotfix-package-2-for-microsoft-application-virtualization-5-0-service-sp2-is-now-available.aspx
    Nicke Källén | The Knack| Twitter:
    @Znackattack

  • I developed app in mac 10.6.8 with xcode 3.2.6.how can i run this app in ipad device

    i developed app in mac 10.6.8 with xcode 3.2.6.how can i run this app in ipad device

    actually i planned to get  provisioning profiles from apple by paying 99$ in following website
    https://developer.apple.com/programs/start/ios/ and followed by
    https://developer.apple.com/programs/start/standard/.
    but in last link,following thing were mentioned at bottom -
    Technical Requirements
    You must have an Intel-based Mac running OS X 10.8 Mountain Lion or later to develop and distribute iOS apps and Mac apps.
    but i\m using mac running OS X 10.6.8 snow leopard.
    Doubt:can't i run my app in ipad device?\
    Thank's in advance..

  • Why does a new run once start up program run every time I start my computer? The start up program is coming from Reader XI. The only name on it is a number starting with 141_______.

    Why does a new run once start up program run every time I start my computer? The start up program is coming from Reader XI. The only name on it is a number starting with 141_______.

    See also https://forums.adobe.com/thread/1654402

  • Help changing a run continuously VI into a run once

    Hi,
    I know that I am probably going to invoke the wrath of the labview gods with this request by not going through my tutorials again but I am unfortunately stuck and
    getting a bit of a brain freeze on this one.
    I have a VI for a flow meter, that runs perfect when I hit run continously but I need to add this to another VI that just runs once so I am trying to convert. 
    I have had previous suggestions in another thread to replace the for loop with a while loop. Add a Stop button on the front panel and wire it to the Stop it True terminal in the loop.
    Move the Waveform Chart and Flow Rate terminals inside the loop. I have done this but the VI does not run correctly, the dial just keep accumalating/adding and not resetting.
    Any alternate approaches that I can try would be greatly appreciated.
    Thank you.
    Attachments:
    Flow Meter 2.vi ‏56 KB

    I tried to do some cleanup and got away from that stupid Express VI.  Your loops really should be combined otherwise you have one nasty race condition with your local variable.  I also found a nice property node for the counter to reset its count.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Flow Meter 4.png ‏41 KB

  • Using an own function in a select how can i set that the function run once?

    Hi
    Using an own function in a select how can i set that the function run once, not in every row?
    Please help me
    Thanks
    Viktor

    Something like this ?
    SQL> select * from dept;
        DEPTNO DNAME                          LOC
            10 ACCOUNTING                     NEW YORK
            20 RESEARCH                       DALLAS
            30 SALES                          CHICAGO
            40 OPERATIONS                     BOSTON
    SQL> create or replace function ret_name (deptnum in number) return varchar2
      2  is
      3     name    varchar2(50);
      4  begin
      5     select dname into name
      6     from dept
      7     where deptno=deptnum;
      8     return name;
      9  exception
    10     when no_data_found then
    11             return('Not existent deptno');
    12* end;
    SQL> /
    Function created.
    SQL> select deptno, decode(rownum,1,ret_name(deptno),null) dname from dept;
        DEPTNO DNAME
            10 ACCOUNTING
            20
            30
            40
    SQL>

  • Sql Server Agent: job hasn't run once today. Scheduling problem?

    I created this job yesterday at about 4PM; the view history shows that it last ran successfully at 11:53PM. These are the settings I put:
    Schedule Type: Recurring
    Occurs: Daily
    Recurs every: 1 days(s)
    Occurs every: 5 minute(s)
    Starting at: 05:00:00 PM
    Ending at: 11:59:59 PM
    Start Date: 10/30/2014
    No End Day (selected)
    The job is enabled, but it hasn't run once yet today. I don't want to start it manually because it should've started already. It is currently not running.
    What can the problem be?
    Thanks.
    VM

    The output is:
    Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (X64)
    The length varies, but it's usually a bit over an hour to finish. It's set at 5 minutes so that, as soon as it completes, it runs the job again. The job history yesterday was: 5:48P, 7:03P, 7:43P, 8:58P, 9:53P, 10:58P, 11:53P. The job downloads some files,
    and that's why the job varies in length.
    VM
    I would say there is no point in scheduling a job which runs for 1 hr to run at every 5 mins although as per SQL Server agent logic if job is currently running and it misses schedule it will only start when job is finished. I would say to change logic to
    run every 1 hr.
    Plus I cannot find the support article but I know there was bug where Agent job could miss schedule can you please apply
    SQL Server 2008 R2 SP3. There are 2 reason
    1. it might fix your schedule skipping issue
    2 You would come under purview of extended support. Which I guess is very important.
    You can easily open job activity monitor and look for column Next run date
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • Run Once ?

    I have been looking for a proper "run once" option for policies.
    Checking through here looking for a real run once option, I found a three year old post that suggested that this functionality would be available soon.
    Does anyone have any hints if this will ever make it into the product?
    I cannot use "System Requirements" because it logs an error on each refresh for each server - a pretty foolish decision I think.

    We use zlm to manage about 400 server and when we started the migration project in 2006 I was searching for something like that and found a few one's like webmin or so. But at that stage no one could deliver what we were looking for and as a result we decided to configure our systems using rpm packages. As we develop linux software we needed a rpm build environment and were familiar with building rpm packages. Therefor we build some packages that contain sometimes simple, sometimes complex scripts, that configure the system. They do things like ntp configuration, deactivating some runlevel scripts, activating vnc remote access, creating the syslog and snmp config .... Now after maybe 3 years with that solution, we are still quiet happy with it because we do not have changes very often and keep the config on all system identical. And as we install the zlm client during the autoyast installation of the server, it will pull down those config packages and configure the server right after the installation. No need to add it to a different administration tool, this is all done via zlm.
    This is not a solution for everybody, but for us it's quiet simple and we will continue with it.
    Webmin: Webmin
    I hope this helps a little bit,
    Rainer

  • When I double click run installation, then proceed to restart, I restart the computer,  but when it loads back up, I get an error message, saying I need to restart, whats wrong?

    When I double click run installation, then proceed to restart, I restart the computer,  but when it loads back up, I get an error message, saying I need to restart, whats wrong?

    I get an error message, saying I need to restart, whats wrong?
    That is a "kernel panic".
    Try here.  Resolving Kernel Panics

  • I'm having trouble downloading firefox. The install wizard runs but then I am unable to run the program either from the short cut or the program menu

    Firefox basically stopped working. Would not access any web pages. Internet expolorer works fine so this is not a connectivity issue.
    I tried to re-intall firefox several times (once w firewall off) unsuccessfully. No error messages. The install wizard runs but then I can't start the program. The short cut icon does not look right. It looks like a web page instead of the firefox logo. When I click it I get the message "windows is looking for Firefox.exe".
    It appears as though the exectutable file is not installing.

    It sounds like the acorn had a white background that you grouped with the acorn. Hence when you selected another color the entire object looked red. Look in the layers panel for one acorn and see how many objects make up the acorn. One of the objects for that acorn should have a fill of none or white. That object you can delete. Now try and fill the object with a color and see if it is ok. If it is, you can do the same to the remaining acorns. If not post the AI file and someone can check for you.

  • Just got a new Iphone 5s.  On my Iphone 4 I had to double click to show what apps were running and then to hold my finger on an app to deactivate it.  Do you need to deactivate the apps on the 5s?

    Just got a new Iphone 5s.  On my Iphone 4 I had to double click to show what apps were running and then to hold my finger on an app to deactivate it.  Do you need to deactivate the apps on the 5s?  If so how do you do it. 

    Double tap the home button to reveal the "Recently used Apps" then slide the App preview (not the icon) upwards to quit the App.

  • ? I have a problem with the cloud app. i have downloaded it several times and have no problem. when it runs it then opens up but stays blank so i cant see my apps or download any HELP

    ? I have a problem with the cloud app. i have downloaded it several times and have no problem. when it runs it then opens up but stays blank so i cant see my apps or download any HELP

    >opens up but stays blank
    BLANK Cloud Screen http://forums.adobe.com/message/5484303 may help
    -and step by step http://forums.adobe.com/thread/1440508?tstart=0
    -and http://helpx.adobe.com/creative-cloud/kb/blank-white-screen-ccp.html

  • Why won't it download? It goes to run, then run, then run again, then extracts and stops downloading. Why won't it work??????

    Firefox won't download at all. It says extracting then stops. I click save then run then run. Then it says extracting then after that it just stops downloading. WHY?!?!?! Annoying.

    Do you get an error? Disable any antivirus or firewall software running on your computer during the update process if you're unpading using iTunes.
    If you're trying to update over the air, try doing it with your computer instead.

  • Run Once Wrapper

    After I have logged in my desktop turns black. Mouse is working and I can start the Taskmanager. When I delete a process called Run Once Wrapper (runonce.exe) I get back the normal desktop and the PC seems to work OK. I have scanned for virus and malware, found no problem. According to HP is this problem caused by a virus.
    Tom
    This question was solved.
    View Solution.

    Hi Tom,
    Stop the process running as you've already done using Taskmanager, then download and run Autoruns on the following link.
    https://technet.microsoft.com/en-us/sysinternals/bb963902.aspx
    Look at what's trying to be launched from the RunOnce wrapper - there will probably be 2 similar entries, one starting HKLM and the other starting HKCU.
    Post back with what's listed.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

Maybe you are looking for