iphone Programming Glossary: blocks
How can I customize an iOS alert view? http://stackoverflow.com/questions/2600779/how-can-i-customize-an-ios-alert-view the second button if it's not being used. The view is actually the size of the entire screen so it blocks touches behind it but it is mostly transparent so the background shows through. When bringing it in..
How to do a natural sort on an NSArray? http://stackoverflow.com/questions/2846301/how-to-do-a-natural-sort-on-an-nsarray p options NSNumericSearch result array sortedArrayUsingFunction sort context @ title Or using blocks result array sortedArrayUsingComparator ^ Obj a Obj b return a title compare b title options NSNumericSearch..
display image from URL retrieved from ALAsset in iPhone http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone resultBlock resultblock failureBlock failureblock A couple of things to note are that this uses blocks which were new to me before I started my iOS4 porting but you might like to look at http www.mikeash.com..
How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:? http://stackoverflow.com/questions/4139219/how-do-you-trigger-a-block-after-a-delay-like-performselectorwithobjectafter withObject afterDelay but with an argument like int double float iphone objective c objective c blocks grand central dispatch share improve this question I think you're looking for dispatch_after . It..
What's the easiest way to get the current location of an iPhone? http://stackoverflow.com/questions/459355/whats-the-easiest-way-to-get-the-current-location-of-an-iphone all that. But I'd like to have a convenience method that just gets the current location once and blocks until it gets the result. iphone core location share improve this question What I do is implement..
Is there a way to make drawRect work right NOW? http://stackoverflow.com/questions/4739748/is-there-a-way-to-make-drawrect-work-right-now on the main thread. Perhaps the easiest way to do this under Snow Leopard and iOS 4.0 is to use blocks like in the following rudimentary sample dispatch_queue_t main_queue dispatch_get_main_queue dispatch_async..
What is the best way to deal with the NSDateFormatter locale “feature”? http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformatter-locale-feature
GCD, Threads, Program Flow and UI Updating http://stackoverflow.com/questions/7290931/gcd-threads-program-flow-and-ui-updating to then update the UI. But you cannot update the UI from a background thread. If you're not using blocks and using performSelectInBackground then when you're done call performSelectorOnMainThread which calls..
How can I customize an iOS alert view? http://stackoverflow.com/questions/2600779/how-can-i-customize-an-ios-alert-view images. I generally only use one or two buttons so I hide the second button if it's not being used. The view is actually the size of the entire screen so it blocks touches behind it but it is mostly transparent so the background shows through. When bringing it in I use a few animations to make it bounce like Apple's alert..
How to do a natural sort on an NSArray? http://stackoverflow.com/questions/2846301/how-to-do-a-natural-sort-on-an-nsarray
display image from URL retrieved from ALAsset in iPhone http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone alloc init autorelease assetslibrary assetForURL asseturl resultBlock resultblock failureBlock failureblock A couple of things to note are that this uses blocks which were new to me before I started my iOS4 porting but you might like to look at http www.mikeash.com pyblog friday qa 2008 12 26.html and http developer.apple.com..
How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:? http://stackoverflow.com/questions/4139219/how-do-you-trigger-a-block-after-a-delay-like-performselectorwithobjectafter primitive parameter after a delay like using performSelector withObject afterDelay but with an argument like int double float iphone objective c objective c blocks grand central dispatch share improve this question I think you're looking for dispatch_after . It requires your block to accept no parameters but you can just..
What's the easiest way to get the current location of an iPhone? http://stackoverflow.com/questions/459355/whats-the-easiest-way-to-get-the-current-location-of-an-iphone so I could do it the hard way with delegates and all that. But I'd like to have a convenience method that just gets the current location once and blocks until it gets the result. iphone core location share improve this question What I do is implement a singleton class to manage updates from core location. To..
Is there a way to make drawRect work right NOW? http://stackoverflow.com/questions/4739748/is-there-a-way-to-make-drawrect-work-right-now any updates you wish to perform to the UI need to be done back on the main thread. Perhaps the easiest way to do this under Snow Leopard and iOS 4.0 is to use blocks like in the following rudimentary sample dispatch_queue_t main_queue dispatch_get_main_queue dispatch_async queue ^ Do some work dispatch_async main_queue ^ Update..
What is the best way to deal with the NSDateFormatter locale “feature”? http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformatter-locale-feature
GCD, Threads, Program Flow and UI Updating http://stackoverflow.com/questions/7290931/gcd-threads-program-flow-and-ui-updating the background thread to do the work and then when it's done to then update the UI. But you cannot update the UI from a background thread. If you're not using blocks and using performSelectInBackground then when you're done call performSelectorOnMainThread which calls a selector to update your UI. performSelectorInBackground..
How can I customize an iOS alert view? http://stackoverflow.com/questions/2600779/how-can-i-customize-an-ios-alert-view buttons so I hide the second button if it's not being used. The view is actually the size of the entire screen so it blocks touches behind it but it is mostly transparent so the background shows through. When bringing it in I use a few animations..
Add UIView Above All Other Views, Including StatusBar http://stackoverflow.com/questions/2666792/add-uiview-above-all-other-views-including-statusbar UIView Above All Other Views Including StatusBar I'm wanting to create a view UIControl which blocks all input and shows a UIActivityIndicatorView while authenticating a user. The UIActionSheet and UIAlertView both manage..
How to do a natural sort on an NSArray? http://stackoverflow.com/questions/2846301/how-to-do-a-natural-sort-on-an-nsarray b valueForKey NSString p options NSNumericSearch result array sortedArrayUsingFunction sort context @ title Or using blocks result array sortedArrayUsingComparator ^ Obj a Obj b return a title compare b title options NSNumericSearch share improve..
NSThread vs. NSOperationQueue vs. ??? on the iPhone http://stackoverflow.com/questions/3041837/nsthread-vs-nsoperationqueue-vs-on-the-iphone subclass solution. It works very well. The NSOperation class is flexible enough that you can use it with invocations blocks or custom subclasses depending on your needs. No matter how you create your NSOperation you can just throw it into an operation..
iOS 4 app crashes at startup on iOS 3.1.3: Symbol not found: __NSConcreteStackBlock http://stackoverflow.com/questions/3313786/ios-4-app-crashes-at-startup-on-ios-3-1-3-symbol-not-found-nsconcretestackbl for any advice iphone ios ios4 share improve this question Ben Gottlieb pointed out yesterday that if you use blocks anywhere in your application you'll see a crash similar to this on a pre 4.0 OS while building with the LLVM compiler. To..
What does this ^ syntax mean in Objective-C? http://stackoverflow.com/questions/3499186/what-does-this-syntax-mean-in-objective-c pass into it FWIW the following is not what it's looking for... void SomeHandler void iphone objective c objective c blocks share improve this question It is a block a new feature Apple added to C in Snow Leopard. Lots more info available at.. feature Apple added to C in Snow Leopard. Lots more info available at http developer.apple.com mac articles cocoa introblocksgcd.html Block Objects Block objects informally œblocks are an extension to C as well as Objective C and C that make it easy.. published both the Blocks Languages Specification and our implementation as open source under the MIT license added blocks support to GCC 4.2 and clang and has submitted it for consideration as part of the next version of the C programming language...
display image from URL retrieved from ALAsset in iPhone http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone asseturl resultBlock resultblock failureBlock failureblock A couple of things to note are that this uses blocks which were new to me before I started my iOS4 porting but you might like to look at http www.mikeash.com pyblog friday qa..
PDF search on the iPhone http://stackoverflow.com/questions/4097044/pdf-search-on-the-iphone on other documents it returns mostly random letters. Maybe it's related to text encoding Someone pointed out that text blocks marked by BT ET operators should be handled instead but I still haven't managed to do so. Anyone managed to extract text..
How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:? http://stackoverflow.com/questions/4139219/how-do-you-trigger-a-block-after-a-delay-like-performselectorwithobjectafter using performSelector withObject afterDelay but with an argument like int double float iphone objective c objective c blocks grand central dispatch share improve this question I think you're looking for dispatch_after . It requires your block..
What's the easiest way to get the current location of an iPhone? http://stackoverflow.com/questions/459355/whats-the-easiest-way-to-get-the-current-location-of-an-iphone with delegates and all that. But I'd like to have a convenience method that just gets the current location once and blocks until it gets the result. iphone core location share improve this question What I do is implement a singleton class..
Is there a way to make drawRect work right NOW? http://stackoverflow.com/questions/4739748/is-there-a-way-to-make-drawrect-work-right-now need to be done back on the main thread. Perhaps the easiest way to do this under Snow Leopard and iOS 4.0 is to use blocks like in the following rudimentary sample dispatch_queue_t main_queue dispatch_get_main_queue dispatch_async queue ^ Do some..
How to create custom easing function with Core Animation? http://stackoverflow.com/questions/5161465/how-to-create-custom-easing-function-with-core-animation acceleration curves in Core Animation But I think it can be made a little simpler and more readable by using blocks. So we can define a category on CAKeyframeAnimation that looks something like this CAKeyframeAnimation Parametric.h this..
Why is autorelease especially dangerous/expensive for iPhone applications? http://stackoverflow.com/questions/613583/why-is-autorelease-especially-dangerous-expensive-for-iphone-applications executes in a more memory constrained environment the use of autorelease pools is discouraged in methods or blocks of code for example loops where an application creates many objects. Instead you should explicitly release objects whenever..
What is the best way to deal with the NSDateFormatter locale “feature”? http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformatter-locale-feature
problem compiling ffmpeg for iFrameExtractor http://stackoverflow.com/questions/6994151/problem-compiling-ffmpeg-for-iframeextractor usr lib system extra cflags arch i386 fmessage length 0 pipe Wno trigraphs fpascal strings O0 fasm blocks Wreturn type Wunused variable D__IPHONE_OS_VERSION_MIN_REQUIRED 40000 isysroot Developer Platforms iPhoneSimulator.platform..
GCD, Threads, Program Flow and UI Updating http://stackoverflow.com/questions/7290931/gcd-threads-program-flow-and-ui-updating then when it's done to then update the UI. But you cannot update the UI from a background thread. If you're not using blocks and using performSelectInBackground then when you're done call performSelectorOnMainThread which calls a selector to update..
Exception Types in iOS crash logs http://stackoverflow.com/questions/7446655/exception-types-in-ios-crash-logs without Objective C objects. Note that a signal is not an exception meaning you can't catch them with @try and @catch blocks. You may set a signal handler with the signal and sigaction functions. Keep in mind some signals like SIGABRT cannot be..
loading images from a background thread using blocks http://stackoverflow.com/questions/7502073/loading-images-from-a-background-thread-using-blocks images from a background thread using blocks I have the following method which basically calls a request to load an array of NSData of images in the background thread..
Are blocks supported in iPhone OS 3.1.3? http://stackoverflow.com/questions/2529973/are-blocks-supported-in-iphone-os-3-1-3 the iPhone 3.1.3 SDK I found conflicting reports on the internet. iphone objective c share improve this question Blocks are not supported natively on the iPhone. However there is an option The plblocks project allows you to compile block based..
What does this ^ syntax mean in Objective-C? http://stackoverflow.com/questions/3499186/what-does-this-syntax-mean-in-objective-c extension to C as well as Objective C and C that make it easy for programmers to define self contained units of work. Blocks are similar to but far more powerful than traditional function pointers. The key differences are Blocks can be defined inline.. units of work. Blocks are similar to but far more powerful than traditional function pointers. The key differences are Blocks can be defined inline as œanonymous functions. Blocks capture read only copies of local variables similar to œclosures in.. than traditional function pointers. The key differences are Blocks can be defined inline as œanonymous functions. Blocks capture read only copies of local variables similar to œclosures in other languages This is kind of functionality is common..
display image from URL retrieved from ALAsset in iPhone http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone pyblog friday qa 2008 12 26.html and http developer.apple.com library ios #documentation Cocoa Conceptual Blocks Articles 00_Introduction.html They bend your head a little but if you think of them as notification selectors or callbacks..
Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints another design approach is this one Note that images will render faster than a CGPDFPageRef Use NSOperations or GCD Blocks to prepare pages ahead of time. call CGContextSetInterpolationQuality ctx kCGInterpolationHigh CGContextSetRenderingIntent..
Blocks instead of performSelector:withObject:afterDelay: [duplicate] http://stackoverflow.com/questions/4007023/blocks-instead-of-performselectorwithobjectafterdelay instead of performSelector withObject afterDelay duplicate This question already has an answer here How do you trigger..
NSURLConnection and grand central dispatch http://stackoverflow.com/questions/5037545/nsurlconnection-and-grand-central-dispatch thread Grand Central Dispatch Concurrent Queue for thread safe data processing not for network programming. By the way Blocks and Grand Central Dispatch sessions are also worth to see. WWDC 2010 Session 206 Introducing Blocks and Grand Central Dispatch.. By the way Blocks and Grand Central Dispatch sessions are also worth to see. WWDC 2010 Session 206 Introducing Blocks and Grand Central Dispatch on iPhone WWDC 2010 Session 211 Simplifying iPhone App Development with Grand Central Dispatch..
How to add userInfo to a UIAlertView? http://stackoverflow.com/questions/5279884/how-to-add-userinfo-to-a-uialertview and you only want one or two buttons you could use this category I made https github.com rsaunders100 UIAlertView Blocks It bypasses the need to add user info since you put your click handeling function straight into the alert. e.g. #import.. need to add user info since you put your click handeling function straight into the alert. e.g. #import UIAlertView Blocks.h ... ... NSString myUserInfo @ example UIAlertView displayAlertWithTitle @ Example Alert View With Blocks message nil.. UIAlertView Blocks.h ... ... NSString myUserInfo @ example UIAlertView displayAlertWithTitle @ Example Alert View With Blocks message nil leftButtonTitle @ Ok leftButtonAction ^ NSLog @ @ myUserInfo rightButtonTitle nil rightButtonAction..
Memory limit and iOS memory allocation in iphone SDK? http://stackoverflow.com/questions/6044147/memory-limit-and-ios-memory-allocation-in-iphone-sdk using well defined data structure allocation iphone ios4 memory management share improve this question Blocks from separate memory allocations are not allocated contiguously separate calls to alloc malloc new etc. . Otherwise they..
Last In-First Out Stack with GCD? http://stackoverflow.com/questions/7567827/last-in-first-out-stack-with-gcd imageView setImage contact.image theCell setNeedsLayout return cell The WWDC2010 conference video Introducing Blocks and Grand Central Dispatch shows an example using the nested dispatch_async as well. another potential optimization could..
ARC, Blocks and Retain Cycles http://stackoverflow.com/questions/7761074/arc-blocks-and-retain-cycles Blocks and Retain Cycles Working on an iOS project that targets 4.0 and 5.0 using ARC. Running into an issue related to blocks..
Use gcc 4.2 in Xcode 4.2 and iOS SDK 5.0 http://stackoverflow.com/questions/7765157/use-gcc-4-2-in-xcode-4-2-and-ios-sdk-5-0 Xcode PrivatePlugIns Xcode3Core.ideplugin Contents SharedSupport Developer Library Xcode Plug ins GCC 4.2 Plausible Blocks .xcplugin Contents Resources GCC 4.2.xcspec Change lines 41 and 42 from this ShowInCompilerSelectionPopup NO IsNoLongerSupported..
How to assign a variable inside a block to a variable outside a block? http://stackoverflow.com/questions/7962721/how-to-assign-a-variable-inside-a-block-to-a-variable-outside-a-block
Is there an advantage to using blocks over functions in Objective-C? http://stackoverflow.com/questions/8647462/is-there-an-advantage-to-using-blocks-over-functions-in-objective-c So simply by using the variable num1 its value at the time myBlock was defined is captured. From Apple's documentation Blocks are a useful alternative to traditional callback functions for two main reasons They allow you to write code at the point.. allow you to write code at the point of invocation that is executed later in the context of the method implementation. Blocks are thus often parameters of framework methods. They allow access to local variables. Rather than using callbacks requiring..
What's the difference between the “global queue” and the “main queue” in GCD? http://stackoverflow.com/questions/9602042/whats-the-difference-between-the-global-queue-and-the-main-queue-in-gcd three priority bands DISPATCH_QUEUE_PRIORITY_HIGH DISPATCH_QUEUE_PRIORITY_DEFAULT DISPATCH_QUEUE_PRIORITY_LOW Blocks submitted to the high priority global queue will be invoked before those submitted to the default or low priority global.. to the high priority global queue will be invoked before those submitted to the default or low priority global queues. Blocks submitted to the low priority global queue will only be invoked if no blocks are pending on the default or high priority..
|