blocks

are objective-c blocks similar to anonymus functions in javascript?

Hi, i am trying to understand the concept of blocks. What i've read so far seems to be conceptually similar to anonymous functions in javascript. Is this correct? ...

Is there a way to determine which view created a block?

Is there a way to determine which view created a block by looking at the block source? ...

[Drupal] View content in blocks depending on selected language

How can i display content nodes in blocks depending on the selected language by the user? I already know how to do it for 'normal' nodes, just not in blocks. Edit: I tried to do this with views. Filtering on a node and content translation: language. The problem is, i don't know how to filter two id's (of the nodes), just one. ...

Avoiding making multiple calls to Find.find("./") in Ruby

I am not sure what is the best strategy for this. I have a class, where I can search the filesystem for a certain pattern of files. I want to execute Find.find("./") only once. how would I approach this: def files_pattern(pattern) Find.find("./") do |f| if f.include? pattern @fs << f end end end ...

UIButton block equivalent to addTarget:action:forControlEvents: method?

I looked around, but couldn't find this on the internet, nor anywhere in the Apple docs, so I'm guessing it doesn't exist. But is there a iOS4 blocks equivalent API to: [button addTarget:self action:@selector(tappy:) forControlEvents:UIControlEventTouchUpInside]; I suppose this could be implemented using a category, but would rather ...

Smalltalk blocks in Objective-c?

Does Objective-C support blocks "a la Smalltalk"? In Smalltalk, blocks are similar to "closures" or "lambda-expressions" or "nameless functions" found in other languages. ...

Objective C Blocks: Is there a way to avoid 'self' being retained?

Hello everyone, I'm trying to write this down as concisely as possible, but it's not easy to describe -- so thanks for reading =) I'm the main developer of the Open Source iPhone Framework Sparrow. Sparrow is modeled after the Flash AS3 Library, and thus has an event system just like AS3. Currently, that system works by specifying sele...

Unique items from a NSMutableArray with NSDictionary items?

If you have an NSMutableArray with three NSDictionarys like this: { name:steve, age:40; name:steve, age:23; name:paul, age:19 } How do I turn that into an array with just two strings { steve, paul }. In other words, the unique names from the original NSMutableArray? Is there a way to do this using blocks? ...

Iteratively filling an array with hashes from an each/do block gives me all repeat values..help!

I am trying to fill an array of hashes with hashes created through an each loop, If I print each individual hash within the iteration they are distinct, but when I try to push them to an array, the resulting array has the last hash repeated whatever number of times. Here's the code: def get_tweets tweet_array = Array.new tweet = {} ...