기본적으로 스택 오버플로 오류를 수정하는 데 도움이 필요합니다. 내 ipad/iphone 앱에 계속 머물러 있습니다. 나는 지난 10 일 동안 그것을 고치려고 노력했지만 아무 소용이 없다.스택 오버플로 오류, 재귀 없음
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
이 UITextField에서 문자/문자열이 변경 될 때마다 한 번 호출되는 이후 재귀가 발생하지 않습니다./THUMB을 ARM에 기본적으로 진수로 변환
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if(textField == m_curValueField)
{
if([string rangeOfCharacterFromSet:[[NSCharacterSet characterSetWithCharactersInString:@"ABCDEFabcdef"] invertedSet]].location != NSNotFound)
{
return NO;
}
NSString *addedString = m_curValueField.text;
addedString = [addedString stringByReplacingCharactersInRange:range withString:string];
if(m_instructionType == TYPE_1)
{
if(addedString.length > 4)
return NO;
}
else if(m_instructionType == TYPE_2)
{
if(addedString.length > 8)
return NO;
}
NSString *result = @"UNDEFINED";
if([m_curValueField.text isEqualToString:addedString])
{
return NO;
}
if(m_instructionType == TYPE_THUMB)
{
if(addedString.length == 4)
{
NSString *temp = @"";
temp = [temp stringByAppendingString:m_curValueField.text];
temp = [temp stringByAppendingString:string];
NSString *firstByte = [temp substringWithRange:NSMakeRange(0, 2)];
NSString *secondByte = [temp substringWithRange:NSMakeRange(2, 2)];
temp = [NSString stringWithFormat:@"%@%@",secondByte,firstByte];
uint16_t bytes;
memcpy(&bytes, [temp cStringUsingEncoding:NSASCIIStringEncoding], sizeof(uint16_t));
char bits [16];
sprintf (bits,BYTETOBINARYPATTERN,BYTETOBINARY(bytes));
result = [m_thumbconverter HexToThumb:bits];
}
}
else if(m_instructionType == TYPE_2)
{
if(addedString.length == 8)
{
NSString *temp = @"";
temp = [temp stringByAppendingString:m_curValueField.text];
temp = [temp stringByAppendingString:string];
NSString *firstByte = [temp substringWithRange:NSMakeRange(0, 2)];
NSString *secondByte = [temp substringWithRange:NSMakeRange(2, 2)];
NSString *thirdByte = [temp substringWithRange:NSMakeRange(4, 2)];
NSString *fourthByte = [temp substringWithRange:NSMakeRange(6, 2)];
temp = [NSString stringWithFormat:@"%@%@%@%@",fourthByte,thirdByte,secondByte,firstByte];
uint32_t bytes;
memcpy(&bytes, [temp cStringUsingEncoding:NSASCIIStringEncoding], sizeof(uint32_t));
char bits[32];
sprintf (bits,BYTETOBINARYPATTERN,BYTETOBINARY(bytes));
result = [m_armconverter HexToARM:bits];
}
}
m_curNewValueField.text = [result copy];
}
return YES;
}
: 기본적으로 여기
내가 문제가있는 부분입니다. HexToThumb/HexToARM 함수는 작동하며 값을 반환합니다. 기본적으로 문제는 m_instructionType이 TYPE_1과 같을 때 스택 오버플로로 인해 응용 프로그램이 충돌한다는 것입니다. 그러나 TYPE_2와 같으면 새 필드의 값이 그에 따라 변경됩니다. 내가 NSLog 코드를 여러 위치에서 코드가 잘 실행되고 HexToThumb 함수가 올바른 값을 반환하는 것 같습니다. 그것은 계속되고 m_curNewValueField = [결과 복사] 이후의 로그; 실제로 syslog에 표시됩니다. 는, BTW 여기 BYTETOBITPATTERN 및 BYTETOBINARY의 정의입니다 :#define BYTETOBINARYPATTERN "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d"
#define BYTETOBINARY(bytes) \
(bytes & 0x80000000 ? 1 : 0), \
(bytes & 0x40000000 ? 1 : 0), \
(bytes & 0x20000000 ? 1 : 0), \
(bytes & 0x10000000 ? 1 : 0), \
(bytes & 0x8000000 ? 1 : 0), \
(bytes & 0x4000000 ? 1 : 0), \
(bytes & 0x2000000 ? 1 : 0), \
(bytes & 0x1000000 ? 1 : 0), \
(bytes & 0x800000 ? 1 : 0), \
(bytes & 0x400000 ? 1 : 0), \
(bytes & 0x200000 ? 1 : 0), \
(bytes & 0x100000 ? 1 : 0), \
(bytes & 0x80000 ? 1 : 0), \
(bytes & 0x40000 ? 1 : 0), \
(bytes & 0x20000 ? 1 : 0), \
(bytes & 0x10000 ? 1 : 0), \
(bytes & 0x8000 ? 1 : 0), \
(bytes & 0x4000 ? 1 : 0), \
(bytes & 0x2000 ? 1 : 0), \
(bytes & 0x1000 ? 1 : 0), \
(bytes & 0x800 ? 1 : 0), \
(bytes & 0x400 ? 1 : 0), \
(bytes & 0x200 ? 1 : 0), \
(bytes & 0x100 ? 1 : 0), \
(bytes & 0x80 ? 1 : 0), \
(bytes & 0x40 ? 1 : 0), \
(bytes & 0x20 ? 1 : 0), \
(bytes & 0x10 ? 1 : 0), \
(bytes & 0x08 ? 1 : 0), \
(bytes & 0x04 ? 1 : 0), \
(bytes & 0x02 ? 1 : 0), \
(bytes & 0x01 ? 1 : 0)
가 대단히 감사합니다.
누구든지 나를 도울 수 있습니까 ??? –