Posts

cocoa touch - how to get uiview to talk to controller -

i'm relatively new objective-c , cocoa... i've been trying understand how correctly implement mvc pattern in cocoa/cocoa touch long time now... understand idea behind it; makes complete sense conceptually: model holds data, view user sees , can interact with, , controller acts bridge between two. view can't talk model, model can't talk view. got it. what doesn't make sense me how use mvc efficiently… if user can interact view, , interact (i.e. iphone app, user clicks/drags within subclass of uiview, triggering "touchesbegan" , "touchesmoved" methods, etc.), how view communicate these events controller? i've looked @ countless examples , forums online, have yet find simplified all-purpose way of achieving this… know how communicate controller through buttons, sliders, , other things can connect outlet, things don't have target-action mechanism, what's best way it? thanks in advance suggestions regarding do, or look. ...

php - preg_match check if string is surrounded in double or single quotes -

can tell me regex see if surrounded in double or single quotes. "this string" i want return false if quotes not present @ or not present @ start , end. preg_match('/^(["\']).*\1$/m', $string); will return 1 if string surrounded double quotes , 0 if not.

Question on URL redirection for wordpress blog -

so long had installed wordpress blog on domain points url this http://www.domainname.com/xxxx/blogs/ now have shifted new hosting, had set blog in following way http://www.domainname.com/blog the search engines have indexed earlier url see same when search in search engines. is there easy way redirect old url new url. thanks in advance karthik you have put .htaccess file , set redirection. .htaccess file in public_html. rewriteengine on rewriterule ^/xxxx/blogs/(.*)$ /blog/$1 [r] this should doo...

Custom Python Encryption algorithm -

hey, have been working on while, , can remebr brother stepped me through same alogorithm. basicly, adds ascii values of both characters key, , phrase. i can encrypt this: def encrypt(key, string): encoded = '' in range(len(string)): key_c = ord(key[i % len(key)]) string_c = ord(string[i % len(string)]) encoded += chr((key_c + string_c) % 127) return encoded but can't seem remember did far decrypting. difficult revers mod :p ideas? that's simple, let's see how works. first of all, encrypted message obtained subtracting key. enc = msg + key (mod 127) how can obtain original message? that's easy, subtract key in both side enc - key = msg + key - key (mod 127) and here get: enc - key = msg (mod 127) for more details, please reference modular arithmetic , think should belong 1 of group/field/ring. i'm not expert in math, deeper theoretical knowledge, can found them in number theory . here refi...

iphone - Setting Property on UIButton in Loop -

i'm spinning in circles on best way implement this, maybe can me out: how can make when uibutton responds selector highlightimage , can set desired challengeid = index of appdelegate.availablearray ? in cellforrowatindexpath method, i'm creating uiscrollview buttons: scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0, 0, tv.frame.size.width, 78)]; [scrollview setcontentsize:cgsizemake(500, 78)]; [self createscrollbuttons]; [[cell contentview] addsubview:scrollview]; my createscrollbuttons loops , creates buttons in scrollview so, looping on number of elements in availablearray - (void) createscrollbuttons { superherogameappdelegate *appdelegate = (superherogameappdelegate *)[[uiapplication sharedapplication] delegate]; int x = 0; int y = 0; nslog(@"challenge array = %@",appdelegate.availablearray); (int = 0; < [appdelegate.availablearray count]; i++) { nslog(@" id= %d", [[[appdelega...

java - How would you test a Connection Pool -

i have implemented simple connectionpool in java. has no fancy features, get/release connection methods. how can test working? i know there plenty of connection pools ready use out there, more reliable i'll do, trying practice understand how connections pool work. thank you! here code in case helps: public class connectionpoolimpl implements connectionpool { private vector<pooledconnection> connections; // connections container string url; string username; string password; /** * instanciates new mysqlconnectionpool * @param nbconnectionsmax */ public connectionpoolimpl(string dburl, string username, string password){ this.connections = new vector<pooledconnection>(); this.url = dburl; this.username = username; this.password = password; } /** * returns connection pool, if available, or create new one. * * @return connection. */ public connection getcon...

Higher level file read/write with Objective-C -

as objective-c superset of c, guess can use fopen/fread/fwrite/fprint... c. does mean objective-c doesn't have unique file processing function? objective-c doesn't have file handling, nor c. however, c standard library does. , if want use objective-c, can use c standard library. objective-c used foundation, -[nsdata writetourl:atomically:] , -[nsstring writetourl:atomically:encoding:error:] can used if link foundation framework. for reading files methods -[nsdata initwithcontentsofurl:options:error:] , -[nsstring initwithcontentsofurl:encoding:error:] .