You could create a subclass of NSFormatter and implement the isPartialStringValid:... method to block the newline.
- (BOOL)isPartialStringValid:(NSString **)partialStringPtr
proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
originalString:(NSString *)origString
originalSelectedRange:(NSRange)origSelRange
errorDescription:(NSString **)error
{
// the user may have:
// -- deleted the left most character
// -- deleted the last character and we have an empty string
// both cases are valid
if (proposedSelRangePtr->location == 0)
return YES;
unichar theChar = [*partialStringPtr characterAtIndex:proposedSelRangePtr->location - 1];
if ([[NSCharacterSet newlineCharacterSet] characterIsMember:theChar]) {
*error = nil;
NSBeep();
return NO;
}
return YES;
}