Comments (5)
Hey @driver733, nothing seems suspicious from this code, though it's super helpful to have it.
Can you add a stack trace by any chance? That exception is being thrown when you are trying to set a result of a task via setResult:
or property access if the task is already completed.
The safer method is trySetResult:
from bolts-objc.
Another piece of feedback about the code - you can get rid of mainTask
and simply return a huge chain of tasks from the method, instead of setting the result manually on a task completion source.
from bolts-objc.
Thanks! I have created a simple method for testing purposes (it raises the same exception)
func test() -> BFTask {
var tasks = [BFTask]()
tasks.append(self.getMovieInfoByITunesID(270711065))
return BFTask(forCompletionOfAllTasksWithResults: tasks)
}
Here`s the stack trace (if I am correctly understanding what you mean :) )
2015-09-05 20:27:45.381 Moviethete[32571:6036338] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot set the result on a completed task.'
*** First throw call stack:
(
0 CoreFoundation 0x035bd746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x03961a97 objc_exception_throw + 44
2 CoreFoundation 0x035bd66d +[NSException raise:format:] + 141
3 Bolts 0x0081cc7e -[BFTask setResult:] + 142
4 Bolts 0x0081fdf7 -[BFTaskCompletionSource setResult:] + 119
5 Moviethete 0x000a448b _TFFV10Moviethete4Post22getMovieInfoByITunesIDFS0_FSiCSo6BFTaskU_FTGSqSS_GSqCSo7NSError__T_ + 1499
6 Moviethete 0x0009facd _TPA__TFFV10Moviethete4Post22getMovieInfoByITunesIDFS0_FSiCSo6BFTaskU_FTGSqSS_GSqCSo7NSError__T_ + 77
7 ITunesSwift 0x03446a9b _TFFC11ITunesSwift15ITunesLookupApi7requestFS0_FFTGSqSS_GSqCSo7NSError__T_T_U_FTGSqCSo12NSURLRequest_GSqCSo17NSHTTPURLResponse_GO9Alamofire6ResultSS__T_ + 683
8 ITunesSwift 0x034460d4 _TPA__TFFC11ITunesSwift15ITunesLookupApi7requestFS0_FFTGSqSS_GSqCSo7NSError__T_T_U_FTGSqCSo12NSURLRequest_GSqCSo17NSHTTPURLResponse_GO9Alamofire6ResultSS__T_ + 100
9 Alamofire 0x00739ece _TTRXFo_oGSqCSo12NSURLRequest_oGSqCSo17NSHTTPURLResponse_oGO9Alamofire6ResultSS__dT__XFo_oGSqS__oGSqS0__iGS2_SS__dT__ + 94
10 Alamofire 0x007372e4 _TPA__TTRXFo_oGSqCSo12NSURLRequest_oGSqCSo17NSHTTPURLResponse_oGO9Alamofire6ResultSS__dT__XFo_oGSqS__oGSqS0__iGS2_SS__dT__ + 100
11 Alamofire 0x00738ea5 _TFFFC9Alamofire7Request8responseu0_Rq_S_18ResponseSerializerzq0_qq_S1_16SerializedObject_FS0_FT5queueGSqPSo17OS_dispatch_queue__18responseSerializerq_17completionHandlerFTGSqCSo12NSURLRequest_GSqCSo17NSHTTPURLResponse_GOS_6Resultq0___T__DS0_U_FT_T_U0_FT_T_ + 517
12 Alamofire 0x00737fa6 _TPA__TFFFC9Alamofire7Request8responseu0_Rq_S_18ResponseSerializerzq0_qq_S1_16SerializedObject_FS0_FT5queueGSqPSo17OS_dispatch_queue__18responseSerializerq_17completionHandlerFTGSqCSo12NSURLRequest_GSqCSo17NSHTTPURLResponse_GOS_6Resultq0___T__DS0_U_FT_T_U0_FT_T_ + 166
13 Alamofire 0x00700c68 _TTRXFo__dT__XFdCb__dT__ + 40
14 libdispatch.dylib 0x044775ea _dispatch_call_block_and_release + 15
15 libdispatch.dylib 0x04499bef _dispatch_client_callout + 14
16 libdispatch.dylib 0x0447f6bb _dispatch_main_queue_callback_4CF + 993
17 CoreFoundation 0x035168ee __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
18 CoreFoundation 0x034d45f0 __CFRunLoopRun + 2256
19 CoreFoundation 0x034d3a5b CFRunLoopRunSpecific + 443
20 CoreFoundation 0x034d388b CFRunLoopRunInMode + 123
21 GraphicsServices 0x066d82c9 GSEventRunModal + 192
22 GraphicsServices 0x066d8106 GSEventRun + 104
23 UIKit 0x020c90b6 UIApplicationMain + 1526
24 Moviethete 0x000aa89c main + 140
25 libdyld.dylib 0x044c4ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
from bolts-objc.
It's crazy hard to read a stack trace from Swift, it's all mangled...
My rough assumption from the stack trace is that setting the result of the task inside getMovieInfoByITunesID
happens twice in your code.
Two things that come to my mind:
- Try replacing setting the result of a task completion source with
trySetResult()
instead ofsetResul()
. - Try adding breakpoints in the completion of that method to make sure you don't get result called twice from the
iTunes.lookup.request
call.
from bolts-objc.
You were 100% correct with your second guess. Thank you very much!
from bolts-objc.
Related Issues (20)
- Documents not available at 1.9.0 on cocoapods.org. HOT 1
- EXC_BAD_ACCESS in BfTask.m
- Next Version Release? HOT 5
- 7 Semantic Issues in XCode 10.1 with Bolts 1.9.0 HOT 3
- ``` HOT 2
- setException deprecated
- Apple Review HOT 10
- Need the Bolts framework with mac catalyst support HOT 2
- Script build_framework.sh fails HOT 1
- need latest BoltsFramework HOT 1
- Built framework lacks slices HOT 2
- Bolts not updating to 1.9.1
- REMOVE ALL UIWEBVIEW REFERENCES OR TEXT IN README.MD
- IPhone
- Crash BFTask.m - Line 54 Crashed: com.parse.asynctaskqueue.sync SIGABRT ABORT 0x00000001b70da95c HOT 3
- U
- Failed to install apps when using Carthage and Xcode12.5 HOT 1
- Is Bolts relevant in 2022 for handling simple deeplinks opening from Facebook?
- Library not loaded: @rpath/Bolts.framework/Versions/A/Bolts
- Privacy manifest required by Apple
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 bolts-objc.