gpt4 book ai didi

ios - nsdata dataWithBytes 在 iOS7 上导致崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:38:26 27 4
gpt4 key购买 nike

它仅在 iOS7 上崩溃

+(PageSection *)initwithPageSection:_anchor withHeader:_subHeader withDetails:_text withPhoneNumberIfValid:(id)_phoneNo
{
const char *tempAnchor = [_anchor cStringUsingEncoding:[NSString defaultCStringEncoding]];
const char *tempSubHeader = [_subHeader cStringUsingEncoding:[NSString defaultCStringEncoding]];
const char *tempText = [_text cStringUsingEncoding:[NSString defaultCStringEncoding]];
const char *tempPhoneNo = [_phoneNo cStringUsingEncoding:[NSString defaultCStringEncoding]];

NSData *anchorData = [NSData dataWithBytes:tempAnchor length:[_anchor length]];
NSData *subHeaderData = [NSData dataWithBytes:tempSubHeader length:[_subHeader length]];
NSData *textData = [NSData dataWithBytes:tempText length:[_text length]];
NSData *phoneData = [NSData dataWithBytes:tempPhoneNo length:[(NSString *)_phoneNo length]];



PageSection *p =[[PageSection alloc]init];
p.anchorTag=[[NSString alloc] initWithData:anchorData encoding:NSUTF8StringEncoding];
p.subHeader=[[NSString alloc] initWithData:subHeaderData encoding:NSUTF8StringEncoding];
p.text=[[NSString alloc] initWithData:textData encoding:NSUTF8StringEncoding];
p.phoneNo=[[NSString alloc] initWithData:phoneData encoding:NSUTF8StringEncoding];
return p;
}

这一行可能会导致崩溃:NSData *textData = [NSData dataWithBytes:tempText length:[_text length]];

有什么想法吗??

最佳答案

实际上它返回 NULL 但仅适用于 iOS7 const char *tempText = [_text cStringUsingEncoding:[NSString defaultCStringEncoding]]; NSLog(@"tex: %s", tempText);

这就是它崩溃的原因

关于ios - nsdata dataWithBytes 在 iOS7 上导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20143700/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com