Skip to main content

Posts

Showing posts with the label class

Objective C create new class which is an image?

Sorry I'm new to Objective C and OOP, and I'm trying to understand how to use classes. I have searched everywhere but can't find a clear answer. So in my game I want a NEW ball to be created when i tap and drag an image of a ball. Would I create a ball class, and when I tap the ball, an instance of the ball class will be created. How do I set that class to be an image of a ball?

Does using method chaining in PHP cause any problems with resources or memory?

I'm talking about methods like this: $object->method()->method1('param')->method2('param'); Those are created by returning the object in the function. return $this; I've seen third-party software use that method, but I'm wondering, wouldn't that cause a bit of a problem with the resources or memory because you're continuously returning the entire object?

Multiple object selection with jQuery

I have a pretty basic jQuery question and forgive me if it has already been answered. Basically I attempt to have a link slide down a div. This is fairly simple however I require multiple links sliding down their respective divs. I understand I can just name the links and divs unique classes and solve the problem that way, however this naturally also requires a duplication of the jQuery code for each link-div and i have a lot. I therefore need a general script. A simplified version of my situation is as follows: HTML: <div> <a id=link1>toggle text 1</a> <div class=link1>TEXT 1</div> <a id=link2>toggle text 2</a> <div class=link2>TEXT 2</div> </div> My attempt at a jQuery general script for this: $(document).ready(function() { $('[id^=link]').bind('click', function() { var $div = $(this).attr('id'); if($('[class=' + div + ']').is(':visible

Common Code for Activity and PreferenceActivity

I'm using common code in my Activity like this: abstract class CommonCode extends Activity { //Common Code here... } then in my "Activity" I extend CommonCode instead of Activity and it all works fine. My problem arise when I try to use commoncode in a PreferenceActivity, I tried: abstract class CommonCode extends Activity { class CommonCodePreferences extends PreferenceActivity { } //Common Code here... } but it isn't right. How can I do it?

Calling a Class function without using $this->function_name() &mdash; PHP --

So I have this class: class A{ public function do_a(){ return 'a_done';}; public function do_b(){ return 'b_done';}; } So I require the php file and create an instance of the class: require_once("A_class.php"); $System = new A(); require_once("user_calls.php"); //here I import the user file with the function calls. user_calls.php contents: echo 'this was the result of '.$System->do_a(); echo 'this was the result of '.$System->do_b(); So, that does work, but I don't want the user to have to use $System->do_a(); , but only do_a(); . Any solutions? EDIT: I also want to limit the functions the user could call in the user_calls.php file, to basic native php functions and those in class A.