Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

iphone - Cancel NSOperation in for loop? -


i trying implement search on background thread using nsoperation on ios. didn't want subclass nsoperation i'm doing:

[searchqueue cancelalloperations]; nsinvocationoperation *op = [[nsinvocationoperation alloc] initwithtarget:self                                                                   elector:@selector(filtercontentforsearchtext:)                                                                    object:self.searchdisplaycontroller.searchbar.text]; [searchqueue addoperation:op]; [op release]; 

the search method includes loop checks whether being searched in array. when cancel nsoperation calling cancelalloperations, loop continues run through array. prevent , wondering whether legit call within loop:

if ([[[searchqueue operations] objectatindex:0] iscancelled]) {     [tmp_array release];   // tmp_array used hold temporary results     [pool drain];          // pool autorelease pool     return; } 

one of reasons subclass nsoperation implement proper cancellation. approach, violates several design principles. basically, since cancellation requires cooperation of operation itself, nsinvocationoperation isn't built cancel invocation while it's executing (though can cancelled before starts executing), running method shouldn't know how it's called.

instead, if subclass nsoperation, can put of functionality main method easily:

@implementation myoperation - (void)main {     if ([self iscancelled])         return;      (...) {         // stuff          if ([self iscancelled]) {             [tmp_array release];             return;         }     } }  @end 

note don't have maintain own autorelease pool such implementation.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -