Giter Club home page Giter Club logo

Comments (4)

ideawu avatar ideawu commented on August 22, 2024

注释里已经说非常清楚了, 因为这是单独的线程. 你需要搜索一下iOS多线程相关的资料. 简单点说, 就是要

dispatch_async(dispatch_get_main_queue()...

from icomet.

chengsan avatar chengsan commented on August 22, 2024

好的,感谢

from icomet.

chengsan avatar chengsan commented on August 22, 2024

能给个简单的事例吗,照你的方法好像不行
// this function is called in a separated thread, it gets called when receive msg from icomet server
//回调接口
size_t icomet_callback(char _ptr, size_t size, size_t nmemb, void *userdata)
{
const size_t sizeInBytes = size_nmemb;
NSData data = [[NSData alloc] initWithBytes:ptr length:sizeInBytes];
NSString
s = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

//开启主线程
dispatch_async(dispatch_get_main_queue(), ^
               {

                   if([NSThread isMainThread])
                   {
                       NSLog(@"回到主线程");
                   }
                   [self setTextResult:s];//这句话说self没有定义

               });



return sizeInBytes;

}

from icomet.

ideawu avatar ideawu commented on August 22, 2024

你好, 之前回复的方案不完整, 我已经更新了 wiki 中的示例, 你参考示例代码即可: https://github.com/ideawu/icomet/wiki/iComet-for-iOS-App

from icomet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.