delete a character from a string Xcode - xcode6

I am using the following code to add a character to a mutable string then put it into a textview from a custom keyboard
- (IBAction) press:(id)sender {
[[UIDevice currentDevice] playInputClick];
if (sender == AEE) {
self.BACK.hidden = NO;
A = #"A";
NSLog(#"sender:%#",sender);
}
if (sender == BEE) {
self.BACK.hidden = NO;
A = #"B";
}
if (sender == CEE) {
self.BACK.hidden = NO;
A = #"C";
}
if (sender == DEE) {
self.BACK.hidden = NO;
A = #"D";
}
if (sender == EEE) {
self.BACK.hidden = NO;
A = #"E";
}
if (sender == EFF) {
self.BACK.hidden = NO;
A = #"F";
}
if (sender == ONE) {
self.BACK.hidden = NO;
A = #"1";
}
if (sender == TWO) {
self.BACK.hidden = NO;
A = #"2";
}
if (sender == THREE) {
self.BACK.hidden = NO;
A = #"3";
}
if (sender == FOUR) {
self.BACK.hidden = NO;
A = #"4";
}
if (sender == FIVE) {
self.BACK.hidden = NO;
A = #"5";
}
if (sender == SIX) {
self.BACK.hidden = NO;
A = #"6";
}
if (sender == SEVEN) {
self.BACK.hidden = NO;
A = #"7";
}
if (sender == EIGHT) {
self.BACK.hidden = NO;
A = #"8";
}
if (sender == NINE) {
self.BACK.hidden = NO;
A = #"9";
}
if (sender == ZERO) {
self.BACK.hidden = NO;
A = #"0";
}
if (display.length <= 7) {
[self.display appendString:A];
DONE.hidden = YES;
}
if (display.length == 8) {
DONE.hidden = NO;
}
else {
[self.display appendString:#""];
}
//**THIS IS WHERE I DELETE CHARATERS**
if (sender == BACK) {
[display deleteCharactersInRange:NSMakeRange([display length]-2, 2)];
NSLog(#"display2:%#", display);
if (self.display.length <1) {
BACK.hidden = YES;
}
if (display.length < 8) {
DONE.hidden = YES;
}
}
you.text = display;
}
When I use the code to delete characters it works fine with for all the characters 1 - 7. Wherever I am if I hit the backspace button it deletes one character. However when I hit the backspace button to delete a character from having 8 characters it deletes two characters. If I change the code to only delete one character like
[display deleteCharactersInRange:NSMakeRange([display length]-1, 1)];
it only deletes one character once. And if I put
[display deleteCharactersInRange:NSMakeRange([display length]-1, 2)];
it does the same thing. But when I put
[display deleteCharactersInRange:NSMakeRange([display length]-2, 1)];
my app crashes and I get an out of bounds error. I have tried using if display =<7 use one the -2,2 code and if display ==8 use the -1,1 code but nothing make it reduce the number of character by one all the time. Does anyone have any suggestions?

I figured out that if I created a separate action to delete and used the following code everything seemed to work ok
(IBAction) Delete:(id)sender{
[[UIDevice currentDevice] playInputClick];
if (sender == BACK) {
if ([display length] > 0) {
[display setString:[display substringToIndex:[display length]-1]];
you.text = display;
}
else {
you.text = display;
//no characters to delete... attempting to do so will result in a crash
}
if (self.display.length <1) {
BACK.hidden = YES;
}
if (display.length < 8) {
DONE.hidden = YES;
}
}

Related

How make sure the 1st (after 0th) segment to be selected on xcode?

When I run my code on the simulator, I can use the left and right button to iterate through the student information, however, my code doesn't seem to display another page (that is connected to subViewController.m) when I press the 1st (after 0th) segment. I am not sure what is wrong in my code. This is my ViewController.m file. Please help and thank you in advance!
//
// ViewController.m
// Storyboard
//
#import "ViewController.h"
#import "Student_Info.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_addStudentButton.hidden = YES;
// Do any additional setup after loading the view, typically from a nib.
_studentInfo = [[NSMutableArray alloc]init];
Student_Info *student1 = [Student_Info new];
student1.name = #"King Richard III";
student1.add = #"Leicester Castle, England";
student1.midtermEx = 72;
student1.finalEx = 45;
student1.homework1 = 9;
student1.homework2 = 10;
student1.homework3 = 00;
student1.image = #"richard.png";
[_studentInfo addObject:student1];
Student_Info *student2 = [Student_Info new];
student2.name = #"Prince Hamlet";
student2.add = #"Elsinore Castle, Denmark";
student2.midtermEx = 100;
student2.finalEx = 0;
student2.homework1 = 10;
student2.homework2 = 10;
student2.homework3 = 10;
student2.image = #"younghamlet.png";
[_studentInfo addObject:student2];
Student_Info *student3 = [Student_Info new];
student3.name = #"King Lear";
student3.add = #"Leicester Castle, England";
student3.midtermEx = 100;
student3.finalEx = 22;
student3.homework1 = 10;
student3.homework2 = 6;
student3.homework3 = 0;
student3.image = #"lear.png";
[_studentInfo addObject:student3];
_subVC = [[subViewController alloc] initWithNibName:#"subViewController" bundle:nil];
_arrayIndex = 0;
}
- (IBAction)leftButtonTapped:(id)sender {
if (_arrayIndex != 0) {
_arrayIndex--;
Student_Info *studObj = (Student_Info*)[_studentInfo objectAtIndex:_arrayIndex];
_studentNameTextField.text = studObj.name;
_studentAddressTextField.text = studObj.add;
_studentMidtermTextField.text = [NSString stringWithFormat:#"%f", studObj.midtermEx];
_studentFinalTextField.text = [NSString stringWithFormat:#"%f", studObj.finalEx];
_studentHWK1TextField.text = [NSString stringWithFormat:#"%i", studObj.homework1];
_studentHWK2TextField.text = [NSString stringWithFormat:#"%i", studObj.homework2];
_studentHWK3TextField.text = [NSString stringWithFormat:#"%i", studObj.homework3];
_letButton.enabled = YES;
_rightButton.enabled = YES;
}
else {
_letButton.enabled = NO;
}
}
- (IBAction)rightButtonTapped:(id)sender {
if (_arrayIndex != [_studentInfo count] - 1) {
_arrayIndex++;
Student_Info *studObj = (Student_Info*)[_studentInfo objectAtIndex:_arrayIndex];
_studentNameTextField.text = studObj.name;
_studentAddressTextField.text = studObj.add;
_studentMidtermTextField.text = [NSString stringWithFormat:#"%f", studObj.midtermEx];
_studentFinalTextField.text = [NSString stringWithFormat:#"%f", studObj.finalEx];
_studentHWK1TextField.text = [NSString stringWithFormat:#"%i", studObj.homework1];
_studentHWK2TextField.text = [NSString stringWithFormat:#"%i", studObj.homework2];
_studentHWK3TextField.text = [NSString stringWithFormat:#"%i", studObj.homework3];
_rightButton.enabled = YES;
_letButton.enabled = YES;
}
else {
_rightButton.enabled = NO;
}
}
-(void) clearAllFields {
_studentNameTextField.text = #"";
_studentAddressTextField.text = #"";
_studentHWK1TextField.text = #"";
_studentHWK2TextField.text = #"";
_studentHWK3TextField.text = #"";
_studentMidtermTextField.text = #"";
_studentFinalTextField.text = #"";
}
- (IBAction)segControlTapped:(id)sender {
UISegmentedControl *segControl = (UISegmentedControl*)segControl;
switch(segControl.selectedSegmentIndex){
case 0 :
_addStudentButton.hidden = YES;
break; /* optional */
case 1 : {
_addStudentButton.hidden = YES;
_subVC.studName = _studentNameTextField.text; //ok
_subVC.studAddress = _studentAddressTextField.text;
Student_Info *obj = [_studentInfo objectAtIndex:_arrayIndex];
_subVC.imgName = obj.image;
break; /* optional */
}
case 2 : {
[self clearAllFields];
_letButton.enabled = false;
_letButton.hidden = YES;
_rightButton.enabled = false;
_rightButton.hidden = YES;
break; /* optional */
}
default : /* Optional */
//statement(s);
break;
}
if (segControl.selectedSegmentIndex == 1) {
[self presentViewController:_subVC animated:true completion:nil];
}
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
Student_Info *studObj = (Student_Info*)[_studentInfo objectAtIndex:_arrayIndex];
if (textField == _studentNameTextField) {
studObj.name = textField.text;
}
if (textField == _studentAddressTextField) {
studObj.add = textField.text;
}
if (textField == _studentMidtermTextField) {
studObj.midtermEx = textField.text.floatValue;
}
if (textField == _studentFinalTextField) {
studObj.finalEx = textField.text.floatValue;
}
if (textField == _studentHWK1TextField) {
studObj.homework1 = (int)textField.text;
}
if (textField == _studentHWK2TextField) {
studObj.homework2 = (int)textField.text;
}
if (textField == _studentHWK3TextField) {
studObj.homework3 = (int)textField.text;
}
}
- (IBAction)addStudentPressed:(id)sender {
Student_Info *studObj =[Student_Info new];
if (sender == _studentNameTextField) {
studObj.name = _studentNameTextField.text;
}
if (sender == _studentAddressTextField) {
studObj.add = _studentAddressTextField.text;
}
if (sender == _studentMidtermTextField) {
studObj.midtermEx = _studentMidtermTextField.text.floatValue;
}
if (sender == _studentFinalTextField) {
studObj.finalEx = _studentFinalTextField.text.floatValue;
}
if (sender == _studentHWK1TextField) {
studObj.homework1 = (int)_studentHWK1TextField.text;
}
if (sender == _studentHWK2TextField) {
studObj.homework2 = (int)_studentHWK2TextField.text;
}
if (sender == _studentHWK3TextField) {
studObj.homework3 = (int)_studentHWK3TextField.text;
}
[_studentInfo addObject:studObj];
}
#end
In this line:
UISegmentedControl *segControl = (UISegmentedControl*)segControl;
I don't see any declaration for segControl in the code, did you have this property somewhere else? If not, you may probably want to do this instead:
UISegmentedControl *segControl = (UISegmentedControl *)sender;

Reducing the length of a long for/if statement

I'm currently trying to make the code of an app I'm developing a bit more efficient and easier to read. Basically what this does is retrieve an array from NSUserDefaults of player names, and fills in the 6 text boxes (tagged 6-11) with these names. If there isn't an existing array it'll use another set of names. Any ideas for simplifying this code would be appreciated.
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
NSMutableArray *names = [[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:#"nameArray"]];
for (int i = 0; i <= 5; i++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
UITableViewCell *cell = [playerTable cellForRowAtIndexPath:indexPath];
for (UIView *view in cell.contentView.subviews) {
if ([view isKindOfClass:[UITextField class]]) {
UITextField *txtField = (UITextField *)view;
if (txtField.tag == 6) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:0]; }
else {
txtField.text = #"Peter";
}
}
if (txtField.tag == 7) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:1]; }
else {
txtField.text = #"Julia";
}
}
if (txtField.tag == 8) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:2]; }
else {
txtField.text = #"Durgan";
}
}
if (txtField.tag == 9) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:3]; }
else {
txtField.text = #"Bob";
}
}
if (txtField.tag == 10) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:4]; }
else {
txtField.text = #"Iseland";
}
}
if (txtField.tag == 11) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:5]; }
else {
txtField.text = #"Player";
}
}
}
}
}
[self saveNames];
}
Your could do this:
NSArray *defaultNames = #[#"Peter", #"Julia",...];
int offsetIndex = 6;
BOOl needCustomNames = [[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"];
for (UIView *view in cell.contentView.subviews)
{
if ([view isKindOfClass:[UITextField class]])
{
UITextField *txtField = (UITextField *)view;
int index = [txtField tag]-offsetIndex;
if (tag >= 6 && tag <= 11)
{
if (needCustomNames)
textField.text = [names objectAtIndex:index];
else
textField.text = [defaultNames objectAtIndex:index];
}
}
}
For example, you called too many times the same lines in the for loop, like checking if you need to use or not a custom names (NSUserDefaults line).
I use an NSArray for the custom names to mimic the same logic, and used an offset to clarify it.
I would recommend to analyse your Code for redundance and exclude them in separate methods. so you have to call only the extern method than every code-party again and again.

UITableView values don't match its key form plist

I am making a plist viewer and editor for iOS, but the problem I have it, that the values don't match to its key. Like I have this plist
{
BuildMachineOSBuild = 12C54;
CAProcessCanAccessGPU = 1;
CFBundleAllowMixedLocalizations = 1;
CFBundleDevelopmentRegion = English;
CFBundleDisplayName = iAd;
CFBundleExecutable = AdSheet;
CFBundleIconFiles = (
"iAd.png",
"iAd#2x.png"
);
CFBundleIcons = {
CFBundlePrimaryIcon = {
CFBundleIconFiles = (
"iAd.png",
"iAd#2x.png"
);
UIPrerenderedIcon = 0;
};
};
CFBundleIdentifier = "com.apple.AdSheetPhone";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleName = AdSheet;
CFBundlePackageType = APPL;
CFBundleResourceSpecification = "ResourceRules.plist";
CFBundleShortVersionString = "1.0";
CFBundleSignature = "????";
CFBundleSupportedPlatforms = (
iPhoneOS
);
CFBundleVersion = "1.0";
CLSystemService = 1;
CLVisibleImmediately = 1;
CanInheritApplicationStateFromOtherProcesses = 1;
DTCompiler = "com.apple.compilers.llvm.clang.1_0";
DTPlatformBuild = "";
DTPlatformName = iphoneos;
DTPlatformVersion = "7.0";
DTSDKBuild = 11A450;
DTSDKName = "iphoneos7.0.internal";
DTXcode = 0500;
DTXcodeBuild = 5A1344i;
MinimumOSVersion = "7.0";
NSPrincipalClass = ADSApplication;
SBAppTags = (
hidden
);
SBMachServices = (
"com.apple.AdSheetPhone.server",
"com.apple.AdSheetPhone.management",
"com.apple.uikit.viewservice.com.apple.AdSheetPhone"
);
UIBackgroundModes = (
continuous
);
UIDeviceFamily = (
1,
2
);
UIShouldIgnoreRemoteControlEvents = 1;
UIStatusBarHidden = 1;
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
UIViewServiceUsesNSXPCConnection = 1;
}
)
I try to display the value and its key (or Dictionary for Dictionaries, Array for Arrays and Bool for Bools)
Then for example CanInheritApplicationStateFromOtherProcesses should show a 1 (wich is a BOOL), but is don't show any value. And CanInheritApplicationStateFromOtherProcesses is on index 0 of my UITableView, but it is on index 19 of the plist. Does anyone know how to fix this error. I am displaying the key in the cell.textLabel.text and the value in cell.detailTextLabel.text. Here is my code of - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"plist Cell" forIndexPath:indexPath];
id obj;
cell.textLabel.adjustsFontSizeToFitWidth = YES;
cell.detailTextLabel.minimumScaleFactor = 0.5;
cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
cell.editingAccessoryType = UITableViewCellEditingStyleNone;
if (self.plistDict) {
NSString* key = [[self.plistDict allKeys] objectAtIndex:indexPath.row];
cell.textLabel.text = key;
obj = [self.plistDict objectForKey:key];
} else {
cell.textLabel.text = [NSString stringWithFormat:#"%li", (long)indexPath.row];
obj = [self.plistArray objectAtIndex:indexPath.row];
}
if(([obj isKindOfClass:[NSArray class]] || [obj isKindOfClass:[NSMutableArray class]]) && cell.tag == 0){
cell.detailTextLabel.text = NSLocalizedString(#"Array", nil);
cell.tag = 1;
return cell;
} if(([obj isKindOfClass:[NSDictionary class]] || [obj isKindOfClass:[NSMutableDictionary class]]) && cell.tag == 0){
cell.detailTextLabel.text = NSLocalizedString(#"Dictionary", nil);
cell.tag = 2;
return cell;
} if ([obj isKindOfClass:[NSString class]] && cell.tag == 0) {
cell.detailTextLabel.text = [NSString stringWithFormat:#"%#", (NSString *)obj];
cell.tag = 3;
return cell;
} if ([obj isKindOfClass:[NSNumber class]]) {
if ([obj isKindOfClass:[#(YES) class]] && cell.tag == 0) {
[boolSwitch setOn:(BOOL)obj animated:YES];
[cell.contentView addSubview:boolSwitch];
cell.detailTextLabel.textColor = [UIColor clearColor];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.tag = 7;
return cell;
} else if (![obj isKindOfClass:[#(YES) class]] && cell.tag == 0) {
cell.detailTextLabel.text = [NSString stringWithFormat:#"%#", (NSNumber *)obj];
cell.tag = 4;
return cell;
} else {
return cell;
}
} if ([obj isKindOfClass:[NSData class]] && cell.tag == 0) {
cell.detailTextLabel.text = NSLocalizedString(#"Data", nil);
cell.tag = 5;
return cell;
} if ([obj isKindOfClass:[NSDate class]] && cell.tag == 0) {
cell.detailTextLabel.text = [NSString stringWithFormat:#"%#", (NSDate *)obj];
cell.tag = 6;
return cell;
} else {
return cell;
}
The odd thing is for the most keys the value matches, but not for all.
cell will be reused with tag. so you maybe should reset the tag before reuse the cell:
//CustomeCell.m
- (void)prepareForReuse{
[super prepareForReuse];
self.tag = 0;
}
Or in tableView delegate class:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
cell.tag = 0;
}

actionSheet clickedButtonAtIndex is not work in objective c?

I try to click button, select from action sheet and then set the selected index to the button text label's text. My button is below. But it not show selected index in button text. How can I solve this?
- (IBAction)cinsiyetBtnClick:(id)sender {
popupQuery1 = [[UIActionSheet alloc] initWithTitle:#"Cinsiyetiniz"
delegate:self
cancelButtonTitle:NO
destructiveButtonTitle:NO
otherButtonTitles:#"Bay", #"Bayan",nil];
popupQuery1.tag = 1;
// popupQuery1.actionSheetStyle = UIActionSheetStyleDefault;
[popupQuery1 showInView:[UIApplication sharedApplication].keyWindow];
[popupQuery1 release];
}
- (IBAction)medeniDurumBtnClick:(id)sender {
popupQuery1 = [[UIActionSheet alloc] initWithTitle:#"Medeni Durumunuz"
delegate:self
cancelButtonTitle:NO
destructiveButtonTitle:NO
otherButtonTitles:#"Evli", #"Bekar",#"Dul",#"Boşanmış",nil];
popupQuery1.tag = 2;
// popupQuery1.actionSheetStyle = UIActionSheetStyleDefault;
[popupQuery1 showInView:[UIApplication sharedApplication].keyWindow];
[popupQuery1 release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(actionSheet.tag==1){
if (buttonIndex == 0) {
self.cinsiyetBtn.titleLabel.text = #"Bay";
} else if (buttonIndex == 1) {
self.cinsiyetBtn.titleLabel.text = #"Bayan";
}
}
else if (actionSheet.tag == 2){
if (buttonIndex == 0) {
self.medeniDurumBtn.titleLabel.text = #"Evli";
} else if (buttonIndex == 1) {
self.medeniDurumBtn.titleLabel.text = #"Bekar";
} else if (buttonIndex == 2) {
self.medeniDurumBtn.titleLabel.text = #"Dul";
} else if (buttonIndex == 3) {
self.medeniDurumBtn.titleLabel.text = #"Boşanmış";
}
}
}
There are several states in which button could be: UIControlStateNormal, UIControlStateHighlighted, UIControlStateSelected and UIControlStateDisabled.
In most cases when you want to update title of button you should set new title for normal state:
[button setTitle:#"New Title" forState:UIControlStateNormal];
Sometimes you would need to set titles for all the states.
So now you should just replace all your self.cinsiyetBtn.titleLabel.text = #"Bay"; with something like this:
[self.cinsiyetBtn setTitle:#"Bay" forState:UIControlStateNormal];

Limit the length of multiple UITextFields

I have four UITextFields, and would like to limit the length of each one, but they are all different lengths. I have the following code so far, but it doesn't quite work correctly
define MAXLENGTH 5
define MAXQTY 3
define MAXSIZE 4
define MAXBRAND 10
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
int lengtha = [brand.text length] ;
NSLog(#"lenghta = %d",lengtha);
if (lengtha >= MAXBRAND && ![string isEqualToString:#""]) {
brand.text = [brand.text substringToIndex:MAXBRAND];
return NO;
}
return YES;
int lengthb = [qty.text length] ;
NSLog(#"lenghtb = %d",lengtha);
if (lengthb >= MAXQTY && ![string isEqualToString:#""]) {
qty.text = [qty.text substringToIndex:MAXQTY];
return NO;
}
return YES;
int lengthc = [size.text length] ;
NSLog(#"lenghtc = %d",lengtha);
if (lengthc >= MAXSIZE && ![string isEqualToString:#""]) {
size.text = [size.text substringToIndex:MAXSIZE];
return NO;
}
return YES;
int lengthd = [price.text length] ;
NSLog(#"lenghtd = %d",lengtha);
if (lengthd >= MAXLENGTH && ![string isEqualToString:#""]) {
price.text = [price.text substringToIndex:MAXLENGTH];
return NO;
}
return YES;
}
If brand, qty, size and price are instance variables (or properties) and are connected to your UITextFields you could try this:
define MAXLENGTH 5
define MAXQTY 3
define MAXSIZE 4
define MAXBRAND 10
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
if (textField == brand) {
int lengtha = [brand.text length];
NSLog(#"lenghta = %d",lengtha);
if (lengtha >= MAXBRAND && ![string isEqualToString:#""]) {
brand.text = [brand.text substringToIndex:MAXBRAND];
return NO;
}
return YES;
} else if (textField == qty) {
int lengthb = [qty.text length];
NSLog(#"lenghtb = %d",lengthb);
if (lengthb >= MAXQTY && ![string isEqualToString:#""]) {
qty.text = [qty.text substringToIndex:MAXQTY];
return NO;
}
return YES;
} else if (textField == size) {
int lengthc = [size.text length];
NSLog(#"lenghtc = %d",lengthc);
if (lengthc >= MAXSIZE && ![string isEqualToString:#""]) {
size.text = [size.text substringToIndex:MAXSIZE];
return NO;
}
return YES;
} else if (textField == price) {
int lengthd = [price.text length];
NSLog(#"lenghtd = %d",lengthd);
if (lengthd >= MAXLENGTH && ![string isEqualToString:#""]) {
price.text = [price.text substringToIndex:MAXLENGTH];
return NO;
}
return YES;
}
return YES;
}