菜鸟教程小白 发表于 2022-12-13 06:30:56

ios - 如何让 NSURLSession 以一定的间隔重复?


                                            <p><p>我很高兴在不使用 <code>NSTimer</code> 对象的情况下让 <code>NSSession</code> 以一定的时间间隔重复自己,我正在寻找是否可以设置 <code>NSURLRequest 的某些属性</code> 还是我忽略的 <code>NSURLSessionConfiguration</code> ? </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>如果你不想使用 NSTimer,你可以使用 long pool 技术,你可以在其中配置 timeoutinterval。</p>

<pre><code>(void)longPoll
{
NSAutoreleasePool *pool = [ init];
NSMutableURLRequest *request    = [ initWithURL: cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];

// --- Your code ---

;
;

;
}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何让 NSURLSession 以一定的间隔重复?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/29747207/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/29747207/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何让 NSURLSession 以一定的间隔重复?