Blocks is Appleās implementation of closures for Objective-C, which are also available for C and C++.
0
votes
0answers
3 views
NSManagedObjectContext performBlock and retain cycles
In the following code, will we run into a retain cycle where context retains the block and the block retains context? Our code base is riddled with this data fetching pattern:
[context ...
0
votes
2answers
16 views
iOS App acting difrently after archiving
while running the app straight from xcode on my phone everything runs great.
after archiving it and running it as an archive the app acts differently and doesn't behave as expected. this is the part ...
0
votes
2answers
28 views
How does one instantiate a block as an instance variable using ARC?
What does one do to make something like this work?
void (^)(void) *someBlock = ^{
//some code
};
3
votes
0answers
50 views
Can anyone explain this anomaly when creating block and copy in one line?
void(^block)() = ^() {double a=0;
}; //works
void(^block)() = ^() {double a=0;
}.copy //won't works;
void(^block)() = (^() {double a=0;
}).copy //this one surprisingly works actually
...
0
votes
1answer
52 views
how to hide a headView of section on UITableView?
i want to hide navigationbar and tabbar on touch and move on uitableview, blow code:
_headView from viewForHeaderInSection it's no problem.
but sometimes after block Executed, _headView is visible
...
2
votes
1answer
39 views
Pattern for specifying that a function's block is asynchronous vs synchronous
Is there a pattern for indicating that a function's blocks are called synchronously or asynchronously, for instance:
- (void)processImage:(UIImage *)image onComplete:(void (^)(NSError ...
0
votes
2answers
27 views
Is it possible to perform an API call in a delegate method that returns a BOOL?
Strange title, I know, but here is the quickest way to explain my issue. The Parse service has a prebuilt Sign Up controller for letting new users sign up for whatever service you may have. There is ...
0
votes
2answers
28 views
Prevent a weakly assigned variable from being dealloc'ed without creating a retain cycle
I have an odd case involving ARC, NSNotificationCenter and a block. The following is a simplified example of the code. From testing it seems that the memory management of didSaveObserver is ...
0
votes
2answers
52 views
How does block comparator work in Obj C?
This is not a how do I do this post. Instead, I want to understand how it works and hopefully others can learn too.
For this example, let's say I have an NSMutableArray with NSDecimalNumber objects ...
-1
votes
2answers
12 views
AFNetworking block and feed
Okay I have another question, tonight, using AFNetworking, i parse my JSON Stream, an add object an MutableArray, when i insert try to print the array outside of the success block, it says null, but ...
0
votes
2answers
23 views
Achieve NSArray merging more elegantly with enumerateObjectsUsingBlock:?
My challenge this week has been to come to terms with blocks in objective-c. There is something about the syntax that does my head in. Getting there.
I have the following code to achieve a merge of ...
0
votes
0answers
12 views
Filter an array: predicate? block?
I'm looking for solutions to filter an array before a second treatment, which could be applied without further tests.
Say I want to delete all files greater than 500K from a given folder. I could:
...
2
votes
1answer
40 views
Does -[NSInvocation retainArguments] copy blocks?
NSInvocation's -retainArguments method is useful for when you don't run the NSInvocation immediately, but do it later; it retains the object arguments so they remain valid during this time.
As we all ...
0
votes
0answers
24 views
SDWebImage not showing randomly in UITableViewCell
Hello I have a script that downloads an image and dynamically sets the UITableView height after it finishes the download, but some images randomly do not show , the curious think is that when i change ...
0
votes
0answers
46 views
objective-c 'double free' error in ARC mode
I'm trying to practice the block and GCD/NSOperation, so I wrote this project Async-objc, but when I'm trying to test it with unit test, I always encountered 'double free' error, I thought there ...