‏إظهار الرسائل ذات التسميات return. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات return. إظهار كافة الرسائل

الجمعة، 20 ديسمبر 2013

return true if strpos !== false

Right, for the 724th time I am missing something stupid here! I know how strpos works, and it is working as expected, but the return in the if function isn't.

Some code:

foreach ($socialstream as $key => $social) { //filtering in here $result= $this->search_objects($social); ....}

My function search_objects:

function search_objects($objects){ $filters = array('word', 'test'); foreach ($objects as $key => $value) { if (is_array($value) || is_object($value)) { $this->search_objects($value); } else { //look for faulty strings in value foreach ($filters as $filter) { if (!is_int($value) && strpos($value, $filter) !== false) { return true; } } } } return false;}

if I print out my $result, I always get false back, unstead of the true in the if function. I know it comes in the if when the needle exists in the haystack, by debugging, it's just not returning it.

soooo, what am I missing? I'm ashamed to have to ask this, but I'm looking at this for a full 2 days now, and deadline is getting close :/


View the original article here

disable/enable return key in UITextField?

One good idea is to create one file to access this class from anywhere. Here is the code:

UIKeyboard.h

#import @interface UIApplication (KeyboardView) - (UIView *)keyboardView; @end

UIKeyboard.m

#import "UIKeyboard.h"@implementation UIApplication (KeyboardView)- (UIView *)keyboardView{ NSArray *windows = [self windows]; for (UIWindow *window in [windows reverseObjectEnumerator]) { for (UIView *view in [window subviews]) { if (!strcmp(object_getClassName(view), "UIKeyboard")) { return view; } } } return nil;}@end

Now you can import and access this class from your own class:

#import "UIKeyboard.h" // Keyboard Instance Pointer. UIView *keyboardView = [[UIApplication sharedApplication] keyboardView];

A full documentation of this class you can find here: http://ericasadun.com/iPhoneDocs/_u_i_keyboard_8h-source.html

More information you can find here: http://cocoawithlove.com/2009/04/showing-message-over-iphone-keyboard.html


View the original article here