Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 15, 2011, 03:52 PM   #1
Richard Birkett
macrumors member
 
Join Date: Aug 2011
NSTextField, Help!

I'm not new to this, but I've taken a break from programming. I say that because it sounds stupid...

My textfield is sending a notification twice! Worse than that, it types the letter twice! Without anything set up it types and acts normally, plain old text field. If I set the appDelegate to the text field's delegate using IB and then use the following code:

Code:
#import <Cocoa/Cocoa.h>
#import "RBMExpression.h"

@interface RBMAppDelegate : NSObject <NSApplicationDelegate>

- (void)controlTextDidChange:(NSNotification *)aNotification;

@property (strong) IBOutlet NSTextField *myTextField;
@property (assign) IBOutlet NSWindow *window;

@end


#import "RBMAppDelegate.h"

@implementation RBMAppDelegate

@synthesize myTextField = _textField;
@synthesize window = _window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
		// Insert code here to initialize your application
}

- (void)controlTextDidChange:(NSNotification *)aNotification
{
	NSString *theString = [_textField stringValue];
	[RBMExpression expressionWithString:theString];
}
@end
It starts double typing each character and sending the notification twice.

Any help appreciated!!!

Richard
Richard Birkett is offline   0 Reply With Quote
Old Dec 15, 2011, 06:46 PM   #2
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
If you comment out the body of your controlTextDidChange: but still leave the delegate connection in place in IB, do you still get this behaviour?
Code:
- (void)controlTextDidChange:(NSNotification *)aNotification
{
	NSLog(@"%s: aNotification=%@", __PRETTY_FUNCTION__, aNotification);
/*
	NSString *theString = [_textField stringValue];
	[RBMExpression expressionWithString:theString];
*/
}
jiminaus is offline   0 Reply With Quote
Old Dec 15, 2011, 07:27 PM   #3
Richard Birkett
Thread Starter
macrumors member
 
Join Date: Aug 2011
Hi,

Sorry, panic over, thanks for replying. It was strange to be fair, it was due to an error in expressionWithString: from trying to get an out of bounds substring of an NSString (using a bad for loop and substringWithRange, I still don't understand fully but it was logging an error amongst my other logs, and for some unknown reason it had to repeat the notification! Fixing the small error fixed this problem.

Thanks,

Richard
Richard Birkett is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
help with dragging a UIImageView on screen mandude iPhone/iPad Programming 3 Nov 28, 2011 12:05 PM
Backup help! robkot iPhone Tips, Help and Troubleshooting 2 Dec 1, 2010 12:04 AM
help with excel for mac 2008 damiang72 Mac Applications and Mac App Store 0 Nov 14, 2010 06:19 AM
video editing help WoblierRex Digital Video 0 Nov 8, 2010 09:23 PM


All times are GMT -5. The time now is 02:26 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC