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

NSanjay

macrumors newbie
Original poster
Jul 7, 2010
1
0
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
 
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.
 
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++.
 
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.
 
Code:
-(IBAction)ShowPreferences:(id)sender
{
	[NSApp beginSheet:PreferencesWindow
	   modalForWindow:mainWindow
		modalDelegate:nil
	   didEndSelector:nil
		  contextInfo:NULL];
}

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.