È possibile eseguire un blocco di completamento sul thread principale?Come posso recuperare un valore di ritorno da un blocco di completamento?
Ad esempio, ho un metodo che restituisce un valore:
- (int)test
{
/* here one method is called with completion block with return type void */
[obj somemethodwithcompeltionblock:
{
/* here I am getting my Int which I want to return */
}
];
}
ma non posso vedere come restituire il valore intero dall'interno del blocco completamento come il risultato di questo metodo, poiché il completamento il blocco viene eseguito su un thread in background.
Come posso fare questo?
Quindi ... non usare un blocco che crea un nuovo thread. È un blocco di framework o di libreria che non puoi modificare? – JoePasq