Comments (6)
from aliyun-log-ios-sdk.
I tried and it CANNOT be produced.
I'm using NSMutableString as a value to insert a log containing 1000000 "1" to test. It runs fine. You may try to check your strtemp's real char.
Check the Developer document stated as follow, your strtemp may contain some string that can not be converted to UTF-8 encoding, I guess you may have some special chars in your string, you may check the doc:
You can use canBeConvertedToEncoding: to check whether a string can be losslessly converted to encoding. If it can’t, you can use dataUsingEncoding:allowLossyConversion: to get a C-string representation using encoding, allowing some loss of information (note that the data returned by dataUsingEncoding:allowLossyConversion: is not a strict C-string since it does not have a NULL terminator).
from aliyun-log-ios-sdk.
感谢回复,我这边采用你说的,试了下一下还是会崩溃的,以下是2种尝试方案
方案一: 如果是通过NSMutableString字符串返回数据确实是没有崩溃
- (NSMutableString*)getTestString{
NSMutableString* content = [[NSMutableString alloc] init];
for (NSInteger i = 0; i < 20000; i++) {
[content insertString:@"1" atIndex:0];
}
NSLog(@"---%ld",content.length);
return content;
}
方案二:这种通过返回字符串做为字典value后上传是有崩溃的 - (NSString*)getTestString2{
NSString* content = @"zifuchuanzifuchuanzifuchuanzifuchuan";
for (NSInteger i = 0; i < 20000; i++) {
content = [content stringByAppendingString:@"zifuchuanzifuchuanzifuchuanzifuchuan"];
}
NSLog(@"---%ld",content.length);
BOOL isFinish = [content canBeConvertedToEncoding:NSUTF8StringEncoding];
NSLog(@"isFinish---%d",isFinish);
return content;
}
调用的方法:
NSString* content = [self getTestString2];
NSDictionary* aLiyunLogDic = @{@"content":content};
//调用日志上传的方法
[[YBAliLogManager shared] uploadLogToInternetWithParameter:aLiyunLogDic finish:^(BOOL isFinish) {
}];
from aliyun-log-ios-sdk.
from aliyun-log-ios-sdk.
``
-(char*)convertToChar:(NSString*)strtemp
{
NSUInteger len = [strtemp lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1;
if (len > 1000000) return strdup([strtemp UTF8String]);
char cStr [len];
[strtemp getCString:cStr maxLength:len encoding:NSUTF8StringEncoding];
return strdup(cStr);
}
- (void)testChar {
NSString* content = @"zifuchuanzifuchuanzifuchuanzifuchuan";
for (NSInteger i = 0; i < 20000; i++) {
content = [content stringByAppendingString:@"zifuchuanzifuchuanzifuchuanzifuchuan"];
}
NSDictionary *dict = @{@"content":content};
char *a = [self convertToChar:dict[@"content"]];
}
``
There is no problem in the above code, you may need to check the code inside the uploadLogToInternetWithParameter block.
from aliyun-log-ios-sdk.
2.3.11版本已经修复
from aliyun-log-ios-sdk.
Related Issues (20)
- 搞毛哦,用swift搞的,还一堆问题;用也用不了,老老实实用oc搞不行吗?肯定不用2年就会没有人维护推到重做 HOT 1
- pod install报错,下载不了 HOT 5
- 沙盒里找不到对应的sqlite文件。 HOT 5
- 如何修改Topic的值呢? HOT 1
- 日志重复上传多条 且 内容不对 HOT 4
- 如何知道每一个log是否上传成功呢? HOT 3
- 集成在RN 0.60以上,项目无法运行。出现错误:Unknown type name 'namespace'等。 HOT 4
- 多个统计行为同时进行,后台出现窜表的问题 HOT 2
- 与Reachability冲突 HOT 1
- AliyunLogProducer -[LogProducerClient AddLog:flush:] + 456 偶先 Crash HOT 1
- iOS 9.1 Crash in Tag 2.3.7 HOT 1
- value传字典crash HOT 1
- 后台看不到上传是数据 HOT 2
- 遇到一个线上crash HOT 3
- 网络质量监控的文档无法访问 HOT 1
- 旧版本获取版本号 HOT 1
- 发送日志报401错误,签名错误 HOT 1
- -[LogProducerClient convertToChar:] 会crash HOT 5
- DestroyLogProducer直接崩溃
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aliyun-log-ios-sdk.