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...
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 ...
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 ...
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.
...
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 ...
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...
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] ...
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...
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...
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...
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...
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...
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.
...
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...
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...
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...
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)?
...
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",...
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...
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...