self

Is it necessary to refer to self in: yield(self[i])

In this example from a blog post, class Array def each i = 0 while(i < self.length) do yield(self[i]) i += 1 end end end my_array = ["a", "b", "c"] my_array.each {|letter| puts letter } # => "a" # => "b" # => "c" Is it necessary to use self in the statement: yield(self[i]) Or would it be ok to simply sa...

Objective C - access BOOL ivar of void pointer to self

I have a thing that uses a SystemSoundID to play a sound, and then repeat with a C function being used as the sound completion callback, and the function is passed (void *)self (since it has to be a void pointer), and then I want to play the sound again if the alarmPlaying BOOL ivar of self is true, otherwise remove the sound completion ...

Connect from iPhone to RESTfull WCF Service with Self Signed Certificate

Hi Guys, I have an iPhone application which has to communicate with a RESTfull WCF service over a secured connection(HTTPS) with a self signed certificate. The WCF service returns XML which is parsed within the app. I have signed the certificate with SelfSSL and installed in on a Windows Server 2003 machine(IIS 6.0). An example of a ...

Instance variable: self vs @

I saw a code class Person def initialize(age) @age = age end def age @age end def age_difference_with(other_person) (self.age - other_person.age).abs end protected :age end What I want to know is how difference between using @age and self.age in age_difference_with method. ...

Why self::function() and $self->variable or self::$variable even though there is $this->function() and $this->variable (PHP)?

I'm confused about these two keywords and the way to use them in PHP5. I think that "this" is used for instanced objects (not static) while "self" is referring to the object itself, not an instance of it and thus used within static objects. Right? Now, I believe that the correct use inside a class's static method to call another static ...

self = Descendant in Ruby?

Hi there, I have a text log from a game with (for example) two types of entries viz. Chat and Event. For the most part they are very similar so I have a LogEntry class defined as so; class LogEntry < Array def initialize(str) super str.split end def parse LogEntry.parse self end def LogEntry.parse(entry) # Proc...

[TSQL] Parent-Child view from table that is self referencing (ID)? (for tsql gurus.)

I have a organization name table with the following structure given below: CREATE TABLE [dbo].[DP_ORG_OrganizationUnit]( [GID] [uniqueidentifier] NULL, [ID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, [Code] [nvarchar](100) NULL, [Name] [nvarchar](100) NULL, [LastUpdated] [datetime] NULL, [ManagedBy] [int] ...

self.delegate = self; what's wrong in doing that?

Hi, self.delegate = self; what's wrong in doing that? and what is the correct way of doing it? Thanks, Nir. Code: (UITextField*)initWith:(id)sender:(float)X:(float)Y:(float)width:(float)hieght:(int)textFieldTag { if (self = [super initWithFrame:CGRectMake(X, Y,width, hieght)]) { finalText = [[NSMutableString alloc] initWith...

Confused when I see 'self' and '__init__'

I don't understand what these are used for, particularly the self argument? Could some please explain this to me and why on earth you would want to pass this in? Also, I've always thought __init__ was for 'initialisation', but it didn't occur to me that I've never had to put anything in here before. Could someone give me an easy example...

UIViewController won't respond to presentModalViewController...

Hey., I've had a UITableViewController-Class. I've changed the UITableViewController Class to UIVIewController and made and specified the connections in IB new. Everything works fine, except [self presentModalViewController:.....] The compiler says that self my not respond to "self" and the app crashes when rotating the view. thanks fo...

[iPhone,Obj-C] What is "self" and how was the "view" property used?

In this: -(IBAction)buttonClick: (id)sender { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Fo Sho?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"fo sho" otherButtonTitles:nil]; [actionSheet showInView:self.view]; } A U...

Self modifying PHP script

Hi all. I'm trying to modify a part of a PHP script structured like this barebone example <-- part A --> function modify_B($string) { some code to modify part B } <-- end A --> <-- part B --> <container>some XML</container> <-- end B --> <-- part C --> <-- end C --> I'd like to modify part B without changing the rest of the fi...

Python: How to avoid explicit 'self'?

I have been learning Python by following some pygame tutorials. Therein I found extensive use of the keyword self, and coming from a primarily Java background, I find that I keep forgetting to type self. For example, instead of self.rect.centerx I would type rect.centerx, because, to me, rect is already a member variable of the class. ...

What side effects should one expect when method decorator replaces self?

I want to execute a method with a copy of the original self passed while execution. Here is the code I'm talking about: def protect_self(func): from copy import copy from functools import wraps @wraps(func) def decorated(self, *args, **kwargs): self_copy = copy(self) return func(self_copy, *args, **kwarg...

Called child´s constant not available in static funcion in parent

I have a static function in a class that needs to be called from several child classes. I need a constant from the calling child class to be available in that function. To have these constants available in other places, the child classes have a function that returns the value of that constant (php 5.2.9). However, when in the parent cla...

copying functions located in instances

Here's some (simplified) code for what I'm trying to do: class a: pass class b: def printSelf(self): print self instOfA = a() instOfB = b() instOfA.printSelf = instOfB.printSelf instOfA.printSelf() <__main__.b instance at 0x0295D238> When I call instOfA.printSelf(), it prints self as being instOfB. But I want sel...

How to make PHP code work without direct calls (on some kind of timer)?

So... for example I want to add to 1 five every 5 minuts (1 is in the DB)... With out direct calls from users.... So... How to make PHP code work without direct calls (on some kind of timer)? ...

Refering to the class itself from within a class mehod in Objective C

I hope i did not skip this part in the ObjC manual but is it possible to refer to a class from within one of its class methods? Like in PHP you would use "this" to refer to the current instance, while "self" refers to the instance's class the ObjC equivalent of "this" would be "self", so what would be the ObjC equivalent of PHP's "self",...

Difference between class property mVar and instance variable self.mVar

I'm some what confused as to the difference between accessing an instance variable via self or just by name (when working inside the class). For instance, take this class: .h: @interface Register : NSObject { NSString *mName; } - (id) initWithName:(NSString *) name; .m: - (id) initWithName:(NSString *)name { if (self == [supe...

How can i present self as a modal view controller?

Hello, I am developing a game using OpenGL. I need to load some images from the web when the game starts (only if there are new ones available). And to do this I decided to create a view controller exactly like Default.png and do the loading there using a UIProgressView. I then added it as subview of my window. Load the images and onc...