Search Results

Search found 13788 results on 552 pages for 'instance'.

Page 24/552 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Cannot assign - must be a "UserProfile" instance

    - by webvulture
    I have a class UserProfile defined which takes the default user as a foreign key. Now another class A has a foreign key to UserProfile. So for saving any instance in class A, how do i give it the userprofile object. Also, does making a class UserProfile mean that class user is still used and class UserProfile is just some other table? I need to know this as I have to take care of the user profile creation, so I should know what gets stored where? -- Confused

    Read the article

  • Create objective-c class instance by name?

    - by Mark
    Duplicate: http://stackoverflow.com/questions/1034350/dynamic-class-creation-in-objective-c/1034368#1034368 Is it possible to create an instance of a class by name? Something like: NSString* className = @"Car"; id* p = [Magic createClassByName:className]; [p turnOnEngine]; I don't know if this is possible in objective-c but seems like it would be, Thanks

    Read the article

  • Groovy Mixin on Instance (Dynamic Mixin)

    - by david
    I'm trying to achieve following: class A { def foo() { "foo" } } class B { def bar() { "bar" } } A.mixin B def a = new A() a.foo() + a.bar() with one significant difference - I would like to do the mixin on the instance: a.mixin B but this results in groovy.lang.MissingMethodException: No signature of method: A.mixin() is applicable for argument types: (java.lang.Class) values: [class B] Is there a chance to get this working like proposed in the Groovy Mixins JSR?

    Read the article

  • How to extend methods to a class not to its instances.

    - by Fraga
    Hi. Extending methods to any instance is really easy: public static string LeaveJustNumbers(this string text) { return Regex.Replace(text, @"[\D]", ""); } ... string JustNumbers = "A5gfb343j4".LeaveJustNumber(); But what if i want to extend methods to a sealed class like string, to work like: string.Format("Hi:{0}","Fraga"); Is there any way to do it?

    Read the article

  • How to create a Uri instance parsed with GenericUriParserOptions.DontCompressPath

    - by Andrew Arnott
    When the .NET System.Uri class parses strings it performs some normalization on the input, such as lower-casing the scheme and hostname. It also trims trailing periods from each path segment. This latter feature is fatal to OpenID applications because some OpenIDs (like those issued from Yahoo) include base64 encoded path segments which may end with a period. How can I disable this period-trimming behavior of the Uri class? Registering my own scheme using UriParser.Register with a parser initialized with GenericUriParserOptions.DontCompressPath avoids the period trimming, and some other operations that are also undesirable for OpenID. But I cannot register a new parser for existing schemes like HTTP and HTTPS, which I must do for OpenIDs. Another approach I tried was registering my own new scheme, and programming the custom parser to change the scheme back to the standard HTTP(s) schemes as part of parsing: public class MyUriParser : GenericUriParser { private string actualScheme; public MyUriParser(string actualScheme) : base(GenericUriParserOptions.DontCompressPath) { this.actualScheme = actualScheme.ToLowerInvariant(); } protected override string GetComponents(Uri uri, UriComponents components, UriFormat format) { string result = base.GetComponents(uri, components, format); // Substitute our actual desired scheme in the string if it's in there. if ((components & UriComponents.Scheme) != 0) { string registeredScheme = base.GetComponents(uri, UriComponents.Scheme, format); result = this.actualScheme + result.Substring(registeredScheme.Length); } return result; } } class Program { static void Main(string[] args) { UriParser.Register(new MyUriParser("http"), "httpx", 80); UriParser.Register(new MyUriParser("https"), "httpsx", 443); Uri z = new Uri("httpsx://me.yahoo.com/b./c.#adf"); var req = (HttpWebRequest)WebRequest.Create(z); req.GetResponse(); } } This actually almost works. The Uri instance reports https instead of httpsx everywhere -- except the Uri.Scheme property itself. That's a problem when you pass this Uri instance to the HttpWebRequest to send a request to this address. Apparently it checks the Scheme property and doesn't recognize it as 'https' because it just sends plaintext to the 443 port instead of SSL. I'm happy for any solution that: Preserves trailing periods in path segments in Uri.Path Includes these periods in outgoing HTTP requests. Ideally works with under ASP.NET medium trust (but not absolutely necessary).

    Read the article

  • ASIHttpRequest problems. "unrecognized selector sent to instance"

    - by Paul Peelen
    Hi, I am experiencing problems using ASIHttpRequst. This is the error I get: 2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890 2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890' 2010-04-11 20:47:08.176 citybikesPlus[5885:207] Stack: ( 33936475, 2546353417, 34318395, 33887862, 33740482, 126399, 445238, 33720545, 33717320, 40085013, 40085210, 3108783, 11168, 11022 ) And this is my code (Part of it): // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [image setImage:[UIImage imageNamed:@"bullet_rack.png"]]; BikeAnnotation *bike = [[annotationView annotation] retain]; bike._sub = @""; [super viewDidLoad]; NSString *newUrl = [[NSString alloc] initWithFormat:rackUrl, bike._id]; NSString *fetchUrl = [newUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [networkQueue cancelAllOperations]; [networkQueue setRequestDidFinishSelector:@selector(rackDone:)]; [networkQueue setRequestDidFailSelector:@selector(processFailed:)]; [networkQueue setDelegate:self]; ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:fetchUrl]] retain]; [request setDefaultResponseEncoding:NSUTF8StringEncoding]; [networkQueue addOperation:request]; [networkQueue go]; } - (void)rackDone:(ASIHTTPRequest *)request { NSString *resultSearch = [request responseString]; NSData *data = [resultSearch dataUsingEncoding:NSUTF8StringEncoding]; NSString *errorDesc = nil; NSPropertyListFormat format; NSDictionary * dict = (NSDictionary*)[NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc]; rackXmlResult* fileResult = [[[rackXmlResult alloc] initWithDictionary:dict] autorelease]; rackXmlSet *rackSet = [fileResult getRackResult]; NSString *subString = [[NSString alloc] initWithFormat:@"Cyklar tillgängligt: %@ -- Lediga platser: %@", rackSet._ready_bikes, rackSet._empty_locks]; [activity setHidden:YES]; [image setHidden:NO]; BikeAnnotation *bike = [annotationView annotation]; bike._sub = subString; } - (void) processFailed:(ASIHTTPRequest *)request { UIAlertView *errorView; NSError *error = [request error]; NSString *errorString = [error localizedDescription]; errorView = [[UIAlertView alloc] initWithTitle: NSLocalizedString(@"Network error", @"Network error") message: errorString delegate: self cancelButtonTitle: NSLocalizedString(@"Close", @"Network error") otherButtonTitles: nil]; [errorView show]; [errorView autorelease]; } The process is loaded as LeftCalloutView in the callout bubble when annotations are loaded in my mapview, so quite a lot (80 times or so). It is meant to retrieve a XML Plist from a server, parse it and use the data... but it dies at the rackDone: Does anybody have any ideas? Regards, Paul Peelen

    Read the article

  • Java-Instance Method Call

    - by Gogi
    When I call as instance method of a class as follows : object_name.function_name(); how the compiler knows that the "function_name" has to be called for that "object_name" behind the scenes ?

    Read the article

  • .Net Com Interop Create Instance Slow

    - by B Z
    I have a .net 4 application that uses a Com Dll to send SMS messages. I used TlbImp to create the interop assembly and that is what is referenced in the application. When I try to create an instance of this class, it takes a really long time (2-5 seconds). I ran performance profile in VS 2010 and the call that takes the longest by far is System.Activator.CreateInstance(). I am looking for tips on how to debug or gotchas with using Com Interop.

    Read the article

  • JavaScript: How to get the instance name of an object

    - by Quandary
    I use the below code to write code to query a web method in a specified interval. now in the this.Poll function I have to do this.tmo = setTimeout(this.strInstanceName + ".Poll()", this.iInterval); instead of this.tmo = setTimeout(this.Poll(), this.iInterval); because IE looses the this object after setTimeout So I have to pass the class it's instance name: var objPoll = new cPoll("objPoll"); How can I get the instance name without passing it as parameter ? I want to have it outta there ! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Intervall-Test</title> <script type="text/javascript" language="javascript"> function test() { alert("Test"); test.tmo = setTimeout(test, 2000); test.Clear = function() { clearTimeout(test.tmo); } } function cPoll(strInstanceName) { this.strInstanceName = strInstanceName ; this.iInterval = 2000; this.tmo=null; this.cbFunction=null; alert(this.Name ); this.Poll = function() { this.cbFunction(); this.tmo = setTimeout(this.strInstanceName + ".Poll()", this.iInterval); } this.Start = function(pCallBackFunction, iIntervalParameter) { if(this.tmo != null) this.Stop(); if(iIntervalParameter && iIntervalParameter > 0) this.iInterval=iIntervalParameter; this.cbFunction=pCallBackFunction; if(this.cbFunction!=null) this.Poll(); else alert("Invalid or no callback function specified"); } this.Stop = function() { if(this.tmo != null) { clearTimeout(this.tmo); this.tmo=null; } } } function CallBackFunction() { alert("PollCallBack"); } // test(); // test.Clear(); var objPoll = new cPoll("objPoll"); </script> </head> <body> <h1>Test</h1> <input type="Button" value="Start polling" onclick="objPoll.Start(CallBackFunction,3000);" /> <input type="Button" value="Stop polling" onclick="objPoll.Stop();" /> </body> </html>

    Read the article

  • How to select and AMI when creating an instance of EC2

    - by Prashant
    I am using Amazon EC2 for the first time, and need to create an instance that runs Windows, MSSQL Server 2008, .Net Framework 3.5 SP1 and IIS Server 6.0. I am unable to decide what AMI (out of the huge list of community AMIs) should I choose to meet my requirements. Is there a way I can make this decision without doing trial and error.

    Read the article

  • SQL Error Locating Server/Instance Specified

    - by leen3o
    Having a problem moving a site from Win2003 IIS6 w/ SQL2005 Express to a Win2008 IIS7 w/Fill SQL 2005? I keep getting this error Desc : SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. Can anyone point me in the right direction

    Read the article

  • Creating IIS Instance over network using MSBuild

    - by Dan
    Is there a way to have MSBuild create an instance of IIS on another remote machine? I do the builds (which occur locally using TeamCity AFAIK), but would like the code to be pushed up to our testing server once the build is completed. I am using IIS 6.x (Windows XP dev and Windows 2k3 Server for testing).

    Read the article

  • One class instance throw all controller

    - by Falcon
    Hello i i have different class and controller. and i need that one instance of model will be available in controller/ now i'm doing something like this: def method1 inst = @MyClass.new(params) inst.action .... def method2 inst = @MyClass.new(params) inst.action .... but i want something like this def method1 @inst.action .... def method2 @inst.action or self.inst i't doesn't matter how i can do it? def self.inst MyClass.new(params) end doesn't work...

    Read the article

  • Printing Instance ID to NSLog?

    - by fuzzygoat
    In the dealloc method for a class how would I print out the ID (or some other unique identifier) for the instance being deallocated? - (void)dealloc { NSLog(@"_deallocing: ??"); [super dealloc]; } Is this possible? I am just trying to get a little more feedback in the console as an aid to learning. many thanks -gary-

    Read the article

  • Subclass not seeing superclass' instance variable

    - by hyn
    I have a situation where my subclass is not seeing the superclass' instance variable x. The ivar is obviously @protected by default, so why do I get a compiler error "x undeclared"? If I make this ivar a property then I can access it by self.x. What's worse is sometimes the error disappears, so something in my code is obviously causing this error but I cannot figure it out.

    Read the article

  • Create class instance in assembly from string name

    - by Arcadian
    I'm not sure if this is possible, and I'm quite new to using assemblies in C#.NET. What I would like to do is to create an instance of a class when supplied the string name of that class. Something like this: using MyAssembly; namespace MyNameSpace { Class MyClass { int MyValue1; int MyValue2; public MyClass(string myTypeName) { foreach(Type type in MyAssembly) { if((string)type == myTypeName) { //create a new instance of the type } } AssignInitialValues(//the type created above) } //Here I use an abstract type which the type above inherits from private void AssignInitialValues(AbstractType myClass) { this.value1 = myClass.value1; this.value2 = myClass.value2; } } } Obviously you cannot compare strings to types but it illustrates what I'm trying to do: create a type from a supplied string. Any thoughts? EDIT: After attempting: var myObject = (AbstractType) Activator.CreateInstance(null, myTypeName); AssignInitialValues(myObject); I get a number of errors: Inconsistent accessibility: parameter type 'MyAssembly.AbstractType' is less accessible than method 'MyNameSpace.MyClass.AssignInitialValues(MyAssembly.AstractType)' 'MyAssembly.AstractType' is inaccessible due to it's protection level The type or namespace name 'MyAssembly' could not be found (are you missing a using directive or an assembly reference?) The type or namespace name 'AbstractType' could not be found (are you missing a using directive or an assembly reference?) Not exactly sure why it can't find the assembly; I've added a reference to the assembly and I use a Using Directive for the namespace in the assembly. As for the protection level, it's calling classes (or rather the constructors of classes) which can only be public. Any clues on where the problem is? UPDATE: After looking through several articles on SO I came across this: http://stackoverflow.com/a/1632609/360627 Making the AbstractTypeclass public solved the issue of inconsistent accessibility. The new compiler error is this: Cannot convert type 'System.Runtime.Remoting.ObjectHandle' to 'MyAssembly.AbstractType' The line it references is this one: var myObject = (AbstractType) Activator.CreateInstance(null, myTypeName); Using .Unwrap() get's me past this error and I think it's the right way to do it (uncertain). However, when running the program I then get a TypeLoadException when this code is called. TypeLoadException: Could not load type ‘AbstractType’ from assembly ‘MyNameSpace'... Right away I can spot that the type its looking for is correct but the assembly it's looking in is wrong. Looking up the Activator.CreateInstance(String, String) method revealed that the null as the first argument means that the method will look in the executing assembly. This is contrary to the required behavior as in the original post. I've tried using MyAssembly as the first argument but this produces the error: 'MyAssembly' is a 'namespace' but is used like a 'variable' Any thoughts on how to fix this?

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >