Search Results

Search found 30000 results on 1200 pages for '2 way object databinding'.

Page 18/1200 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Ongoing confusion about ivars and properties in objective C

    - by Earl Grey
    After almost 8 months being in ios programming, I am again confused about the right approach. Maybe it is not the language but some OOP principle I am confused about. I don't know.. I was trying C# a few years back. There were fields (private variables, private data in an object), there were getters and setters (methods which exposed something to the world) ,and properties which was THE exposed thing. I liked the elegance of the solution, for example there could be a class that would have a property called DailyRevenue...a float...but there was no private variable called dailyRevenue, there was only a field - an array of single transaction revenues...and the getter for DailyRevenue property calculated the revenue transparently. If somehow the internals of daily revenue calculation would change, it would not affect somebody who consumed my DailyRevenue property in any way, since he would be shielded from getter implementation. I understood that sometimes there was , and sometimes there wasn't a 1-1 relationship between fields and properties. depending on the requirements. It seemed ok in my opinion. And that properties are THE way to acces the data in object. I know the difference betweeen private, protected, and public keyword. Now lets get to objectiveC. On what factor should I base my decision about making someting only an ivar or making it as a property? Is the mental model the same as I describe above? I know that ivars are "protected" by default, not "private" asi in c#..But thats ok I think, no big deal for my presnet level of understanding the whole ios development. The point is ivars are not accesible from outside (given i don't make them public..but i won't). The thing that clouds my clear understanding is that I can have IBOutlets from ivars. Why am I seeing internal object data in the UI? *Why is it ok?* On the other hand, if I make an IBOutlet from property, and I do not make it readonly, anybody can change it. Is this ok too? Let's say I have a ParseManager object. This object would use a built in Foundation framework class called NSXMLParser. Obviously my ParseManager will utilize this nsxmlparser's capabilities but will also do some additional work. Now my question is, who should initialize this NSXMLParser object and in which way should I make a reference to it from the ParseManager object, when there is a need to parse something. A) the ParseManager -1) in its default init method (possible here ivar - or - ivar+ppty) -2) with lazyloading in getter (required a ppty here) B) Some other object - who will pass a reference to NSXMLParser object to the ParseManager object. -1) in some custom initializer (initWithParser:(NSXMLPArser *) parser) when creating the ParseManager object.. A1 - the problem is, we create a parser and waste memory while it is not yet needed. However, we can be sure that all methods that are part ot ParserManager object, can use the ivar safely, since it exists. A2 - the problem is, the nsxmlparser is exposed to outside world, although it could be read only. Would we want a parser to be exposed in some scenario? B1 - this could maybe be useful when we would want to use more types of parsers..i dont know... I understand that architectural requirements and and language is not the same. But clearly the two are in relation. How to get out of that mess of my? Please bear with me, I wasn't able to come up with a single ultimate question. And secondly, it's better to not scare me with some superadvanced newspeak that talks about some crazy internals (what the compiler does) and edge cases.

    Read the article

  • How to pass object from one activity to another in android

    - by kaibuki
    Hi I am trying to work on sending an object of my "Customer" class from one activity and display on other activity. the code for the customer class : `package com.kaibuki; public class Customer { private String firstName, lastName, Address; int Age; public Customer(String fname, String lname, int age, String address) { firstName = fname; lastName = lname; Age = age; Address = address; } public String printValues() { String data = null; data = "First Name :" + firstName + " Last Name :" + lastName + " Age : " + Age + " Address : " + Address; return data; } } I want to send its object from one activity to another and then display the data on the other activity. Please need urgent help. Thanks alot Kai`

    Read the article

  • Is learning the Caché database hard coming from relational databases and object oriented programming

    - by Edelcom
    I am currently running the local version of Caché on my system in order to determine if I can (and will) take on a new possible project. The current project uses Delphi 7 as a front end calling a Caché dll where the business logic is stored in the database. I have a background of Sqlserver and Firebird (and before Access and Paradox) as databases. I use Delphi 7 for 95% of my Windows development, so I know about object programming. I would like to recieve opinions from persons having used Caché and either SqlServer, Firebird or Oracle and having developed in Delphi (or C++ or C# - an object oriented language). I have read the pro's and con's from other questions, but I am not asking for this, I need input from Caché developers. Thanks in advance.

    Read the article

  • PHP intersection between array and object

    - by nickf
    I have an object, let's say it's like this: class Foo { var $b, $a, $r; function __construct($B, $A, $R) { $this->b = $B; $this->a = $A; $this->r = $R; } } $f = new Foo(1, 2, 3); I want to get an arbitrary slice of this object's properties as an array. $desiredProperties = array('b', 'r'); $output = magicHere($foo, $desiredProperties); print_r($output); // array( // "b" => 1, // "r" => 3 // )

    Read the article

  • Rails: Object#id will be deprecated; use Object#object_id

    - by sscirrus
    Hi everyone, Very quick question. My server is warning me that line 37 will be deprecated, specifically: #Server error: views/projects/index.html.erb:37: warning: Object#id will be deprecated; use Object#object_id #Views/projects/index.html.erb: 6: <% for project in @projects do %> 36: <%= project.id %> 37: <%= Matching.find_all_by_customer_id_and_project_id( @customer.id, project.id).id %> 38: <%= @customer.id %> Here's my confusion. Line 36 project.id isn't raising a warning, so I assume the issue is that I'm calling ID on the Matching model. Why is it the case that only Matching raising an error and not customer or project? How can I rectify this in my code? Thanks very much.

    Read the article

  • python duration of a file object in an argument list

    - by msw
    In the pickle module documentation there is a snippet of example code: reader = pickle.load(open('save.p', 'rb')) which upon first read looked like it would allocate a system file descriptor, read its contents and then "leak" the open descriptor for there isn't any handle accessible to call close() upon. This got me wondering if there was any hidden magic that takes care of this case. Diving into the source, I found in Modules/_fileio.c that file descriptors are closed by the fileio_dealloc() destructor which led to the real question. What is the duration of the file object returned by the example code above? After that statement executes does the object indeed become unreferenced and therefore will the fd be subject to a real close(2) call at some future garbage collection sweep? If so, is the example line good practice, or should one not count on the fd being released thus risking kernel per-process descriptor table exhaustion?

    Read the article

  • Cast ASP type object to HtmlControl

    - by Joris
    Hey'all How do I cast a li dom element as HtmlControl from an ASP type object? I tried it like this: var li = (HtmlControl)sender; I get a InvalidCastException... The thing is, I want to make the li (a tab) clickable, and then update an UpdatePanel... But when I start like this <li id="li" runat="server" onclick="tab2_Click"> FooBar </li> I get an error because the object is not defined... how to cast?

    Read the article

  • Extending Object in Javasript

    - by smsteel
    I'm trying to extend Object functionality this way: Object.prototype.get_type = function() { if(this.constructor) { var r = /\W*function\s+([\w\$]+)\(/; var match = r.exec(this.constructor.toString()); return match ? match[1].toLowerCase() : undefined; } else { return typeof this; } } It's great, but there is a problem: var foo = { 'bar' : 'eggs' }; for(var key in foo) { alert(key); } There'll be 3 passages of cycle. Is there any way to avoid this?

    Read the article

  • Storing Templates and Object-Oriented vs Relational Databases

    - by syrion
    I'm designing some custom blog software, and have run into a conundrum regarding database design. The software requires that there be multiple content types, each of which will require different entry forms and presentation templates. My initial instinct is to create these content types as objects, then serialize them and store them in the database as JSON or YAML, with the entry forms and templates as simple strings attached to the "contentTypes" table. This seems cumbersome, however. Are there established best practices for dealing with this design? Is this a use case where I should consider an object database? If I should be using an object database, which should I consider? I am currently working in Python and would prefer a capable Python library, but can move to Java if need be.

    Read the article

  • Checking for Value in JS Object

    - by pagewil
    I have a JS Object like so: var ob{ 1 : { id:101, name:'john', email:'[email protected]' }, 2 : { id:102, name:'jim', email:'[email protected]' }, 3 : { id:103, name:'bob', email:'[email protected]' }, } I want to check if this JS object already contains a record. If it doesn't then I want to add it. For example. if(ob contains an id of 101){ //don't add john }else{ //add john } Catch my drift? Pretty simple question. I just want to know the best way of doing it. Thanks Guys! W.

    Read the article

  • 'int' object is not callable

    - by Oscar Reyes
    I'm trying to define a simply Fraction class And I'm getting this error: python fraction.py Traceback (most recent call last): File "fraction.py", line 20, in <module> f.numerator(2) TypeError: 'int' object is not callable The code follows: class Fraction(object): def __init__( self, n=0, d=0 ): self.numerator = n self.denominator = d def get_numerator(self): return self.numerator def get_denominator(self): return self.denominator def numerator(self, n): self.numerator = n def denominator( self, d ): self.denominator = d def prints( self ): print "%d/%d" %(self.numerator, self.denominator) if __name__ == "__main__": f = Fraction() f.numerator(2) f.denominator(5) f.prints() I thought it was because I had numerator(self) and numerator(self, n) but now I know Python doesn't have method overloading ( function overloading ) so I renamed to get_numerator but that's not the problems. What could it be?

    Read the article

  • remove duplicates from object array data java

    - by zahir hussain
    hi i want to know how to remove duplicates in object. for example cat c[] = new cat[10]; c[1].data = "ji"; c[2].data = "pi"; c[3].data = "ji"; c[4].data = "lp"; c[5].data = "ji"; c[6].data = "pi"; c[7].data = "jis"; c[8].data = "lp"; c[9].data = "js"; c[10].data = "psi"; i would like to remove the duplicates value from object array. thanks and advance

    Read the article

  • Test, if object was deleted

    - by justik
    Look to the following code, please: class Node { private: double x, y; public: Node (double xx, double yy): x(xx), y(yy){} }; int main() { Node *n1 = new Node(1,1); Node *n2 = n1; delete n2; n2 = NULL; if (n1 != NULL) //Bad test { delete n1; //throw an exception } } There are two pointers n1, n2 pointed to the same object. I would like to detect whether n2 was deleted using n1 pointer test. But this test results in exception. Is there any way how to determine whether the object was deleted (or was not deleted) using n1 pointer ? Thanks for your help.

    Read the article

  • Learning to think in the Object Oriented Way

    - by SpikETidE
    Hi Everyone.... I am a programmer trying to learn to code in the object oriented paradigm... I mainly work with PHP and i thought of learning the zend framework... So, felt I need to learn to code in OO PHP.... The problem is, having done code using functions for quite a long time, i just can't get my head to think in the OO way.... Also felt that probably I am not the only one facing this problem since the beginning of time... So, how did you people learn object oriented programming... especially how did you succeed in "unlearning" to code using functions... and learn to see you code as objects...? Is there any good resource books or sites where one could find help...?? Thanks for sharing your knowledge and experiences...

    Read the article

  • Can we create a class from a xml file ?

    - by panzerschreck
    Hello, Is it possible to create a class dynamically by reading an xml file ( in java preferably) ? if yes, please provide pointers on how to do it. In the process of development, we have come up with a class that has 5 attributes, all these attributes correspond to an entry in the xml file, now if the user adds/modifies the xml entry the object corresponding to it must change automatically, one approach would be generate the source code, before compile time.Is there any other way ? Is there any common pattern to model such changes in the system ? Thanks,

    Read the article

  • Treeview DatafieldParentID Bind to Object whose property is a another object

    - by user228777
    I am trying to bind Generic collection to a Rad Treeview control. In following case CategoryCollection Returns collection of Category Object, which has bunch of properties and A Parent property which is a object and this parent object Has Id and text properties. What I am trying to do is: I want to Bind DataFieldParentID of the tree view to CategoryCollection.Parent.Id. How do I do that? Dim tvCategory As RadTreeView = DirectCast(cboCategory.Items(0).FindControl("tvCategory"), RadTreeView) With tvCategory .DataSource = CategoryCollection .DataTextField = "Name" .DataValueField = "ID" .DataFieldID = "ID" .DataFieldParentID = "Parent.ID" .DataBind() End With Thank You

    Read the article

  • Python: Hack to call a method on an object that isn't of its class

    - by cool-RR
    Assume you define a class, which has a method which does some complicated processing: class A(object): def my_method(self): # Some complicated processing is done here return self And now you want to use that method on some object from another class entirely. Like, you want to do A.my_method(7). This is what you'd get: TypeError: unbound method my_method() must be called with A instance as first argument (got int instance instead). Now, is there any possibility to hack things so you could call that method on 7? I'd want to avoid moving the function or rewriting it. (Note that the method's logic does depend on self.) One note: I know that some people will want to say, "You're doing it wrong! You're abusing Python! You shouldn't do it!" So yes, I know, this is a terrible terrible thing I want to do. I'm asking if someone knows how to do it, not how to preach to me that I shouldn't do it.

    Read the article

  • Measuring the time to create and destroy a simple object

    - by portoalet
    From Effective Java 2nd Edition Item 7: Avoid Finalizers "Oh, and one more thing: there is a severe performance penalty for using finalizers. On my machine, the time to create and destroy a simple object is about 5.6 ns. Adding a finalizer increases the time to 2,400 ns. In other words, it is about 430 times slower to create and destroy objects with finalizers." How can one measure the time to create and destroy an object? Do you just do: long start = System.nanoTime(); SimpleObject simpleObj = new SimpleObject(); simpleObj.finalize(); long end = System.nanoTime(); long time = end - start;

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >