Need help with my source code !!!

Discussion in 'Mac Programming' started by NSanjay, Jul 7, 2010.

  1. NSanjay macrumors newbie

    Joined:
    Jul 7, 2010
    #1
    Can someone here help take a look at my xcode project & fix it for me ? I really dont know what I am doing wrong in my source code. Thank you.

    Download:

    http://www.mediafire.com/?nzegmdmz2w3

    Code:
    //
    //  MacRarAppDelegate.h
    //  MacRar
    //
    //  Created by Sanjay Nathan on 7/5/10.
    //  Copyright 2010 Sanjay Nathan. All rights reserved.
    //
    
    #import <Cocoa/Cocoa.h>
    
    @interface MacRarAppDelegate : NSObject <NSApplicationDelegate> {
        NSWindow *window;
    	IBOutlet NSTextField *RarLocationTextField;
    	IBOutlet NSTextField *FileLocationTextField;
    	IBOutlet NSPopUpButton *SplitArchivePopUp;
    	IBOutlet NSPopUpButton *CompressionPopUp;
    	IBOutlet NSTextField *PasswordTextField;
    	IBOutlet NSWindow *mainWindow;
    	IBOutlet NSWindow *PreferencesWindow;
    }
    
    NSString *RarLoc;
    NSString *RarDirectory;
    NSDictionary *defaults;
    NSUserDefaults *userDefaults;
    NSString *theRarDirectory;
    
    -(IBAction)ShowPreferences:(id)sender;
    -(IBAction)SelectRar:(id)sender;
    -(IBAction)RarSelected:(id)sender;
    -(IBAction)SelectFile:(id)sender;
    -(IBAction)MakeRar:(id)sender;
    
    @property (assign) IBOutlet NSWindow *window;
    
    @end
    
    Code:
    //
    //  MacRarAppDelegate.m
    //  MacRar
    //
    //  Created by Sanjay Nathan on 7/5/10.
    //  Copyright 2010 Sanjay Nathan. All rights reserved.
    //
    
    #import "MacRarAppDelegate.h"
    
    @implementation MacRarAppDelegate
    
    @synthesize window;
    
    +(void)initialize
    {
    	userDefaults = [NSUserDefaults standardUserDefaults];
    	RarDirectory = [NSString stringWithString:@""];
    	
    	defaults = [NSDictionary dictionaryWithObjectsAndKeys:RarDirectory, @"urls", nil];
    
    	[userDefaults registerDefaults:defaults];
    }
    
    -(void)awakeFromNib
    {
    	userDefaults = [NSUserDefaults standardUserDefaults];
    	theRarDirectory = [userDefaults objectForKey:@"urls"];
    	[RarLocationTextField setString:theRarDirectory];
    }
    
    -(void)updateRarLocation
    {
    	userDefaults = [NSUserDefaults standardUserDefaults];
    	[userDefaults setObject:[RarLocationTextField string]forKey:@"urls"];
    	[userDefaults synchronize];
    }
    
    -(IBAction)ShowPreferences:(id)sender
    {
    	[NSApp beginSheet:PreferencesWindow
    	   modalForWindow:mainWindow
    		modalDelegate:nil
    	   didEndSelector:nil
    		  contextInfo:NULL];
    }
    
    -(IBAction)RarSelected:(id)sender
    {
    	[NSApp endSheet:[sender window]];
    	[[sender window] orderOut:self];
    	
    	RarLoc = [RarLocationTextField string];
    	
    	if ([RarLoc isEqualToString:@""])
    	{
    		return;
    	} else {
    		[NSApp endSheet:[sender window]];
    		[[sender window] orderOut:self];
    	}
    }
    
    -(IBAction)SelectRar:(id)sender
    {
    	
    }
    
    -(IBAction)SelectFile:(id)sender
    {
    	
    }
    
    -(IBAction)MakeRar:(id)sender
    {
    	
    }
    	
    -(void)applicationWillTerminate:(NSNotification *)notification
    {
    	[self updateRarLocation];
    }
    
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    	// Insert code here to initialize your application
    }
    
    @end
    
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    This isn't the proper way to ask for help. Post the relevant code here (be sure to use the code tags) and describe the problems you're having. The forum isn't for having people do your homework.
     
  3. Detrius macrumors 68000

    Joined:
    Sep 10, 2008
    Location:
    Asheville, NC
    #3
    What you're doing wrong is that you aren't feeding the unicorns properly. Therefore, they will revolt and crash your program. You can only feed the unicorns in C++, so you will definitely need to use more C++.
     
  4. object88 macrumors member

    Joined:
    Sep 10, 2008
    #4
    No, Detrius, you've got it all wrong! Unicorns are afraid of C++. He needs to use more UNIXes if he's going to keep the unicorns in his program happy.
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    If you expect something to happen after the sheet ends, your expectation is wrong. You have no delegate and no selector. You are telling NSApp that you have no action to perform after the sheet ends. It's doing what you tell it.

    This code looks like you don't understand how delegates or sheets work. You should probably review that part of whatever book or tutorial you're using. If you're not using a book or tutorial, you should be.

    If you have another expectation for your code, then you need to describe it. You also need to explain how the code isn't meeting your expectation.

    Very few people have the time or inclination to download an entire project and debug it, without knowing how it should work That means you have to explain what you're trying to do and what the problem is.
     
  6. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #6
    Before he reads his book/tutorial, he should read this article on Getting Answers.
     

Share This Page