Search Results

Search found 4350 results on 174 pages for 'chilly child'.

Page 56/174 | < Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >

  • NSNotifications vs delegate for multiple instances of same protocol

    - by Brent Traut
    I could use some architectural advice. I've run into the following problem a few times now and I've never found a truly elegant way to solve it. The issue, described at the highest level possible:I have a parent class that would like to act as the delegate for multiple children (all using the same protocol), but when the children call methods on the parent, the parent no longer knows which child is making the call. I would like to use loose coupling (delegates/protocols or notifications) rather than direct calls. I don't need multiple handlers, so notifications seem like they might be overkill. To illustrate the problem, let me try a super-simplified example: I start with a parent view controller (and corresponding view). I create three child views and insert each of them into the parent view. I would like the parent view controller to be notified whenever the user touches one of the children. There are a few options to notify the parent: Define a protocol. The parent implements the protocol and sets itself as the delegate to each of the children. When the user touches a child view, its view controller calls its delegate (the parent). In this case, the parent is notified that a view is touched, but it doesn't know which one. Not good enough. Same as #1, but define the methods in the protocol to also pass some sort of identifier. When the child tells its delegate that it was touched, it also passes a pointer to itself. This way, the parent know exactly which view was touched. It just seems really strange for an object to pass a reference to itself. Use NSNotifications. The parent defines a separate method for each of the three children and then subscribes to the "viewWasTouched" notification for each of the three children as the notification sender. The children don't need to attach themselves to the user dictionary, but they do need to send the notification with a pointer to themselves as the scope. Same as #4, but rather than using separate methods, the parent could just use one with a switch case or other branching along with the notification's sender to determine which path to take. Create multiple man-in-the-middle classes that act as the delegates to the child views and then call methods on the parent either with a pointer to the child or with some other differentiating factor. This approach doesn't seem scalable. Are any of these approaches considered best practice? I can't say for sure, but it feels like I'm missing something more obvious/elegant.

    Read the article

  • Inheritance of jQuery's prototype partially fails

    - by user1065745
    I want to use Coffeescript to create an UIObject class. This class should inherit from jQuery, so that instances of UIObject can be used as if they where created with jQuery. class UIObject isObject: (val) -> typeof val is "object" constructor: (tag, attributes) -> @merge jQuery(tag, attributes), this @UIObjectProperties = {} merge: (source, destination) -> for key of source if destination[key] is undefined destination[key] = source[key] else if @isObject(source[key]) @merge(source[key], destination[key]) return It partially works. Consider the Foobar class below: class Foobar extends UIObject constructor: -> super("<h1/>", html: "Foobar") $("body").append(new Foobar) works fine. BUT: (new Foobar).appendTo("body") places the tag, but also raises RangeError: Maximum call stack size exceeded. Was it just a bad idea to inherit from jQuery? Or is there a solurion? For those who don't know CoffeeScript, the JavaScript source is: var Foobar, UIObject; var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; UIObject = (function () { UIObject.prototype.isObject = function (val) { return typeof val === "object"; }; function UIObject(tag, attributes) { this.merge(jQuery(tag, attributes), this); this.UIObjectProperties = {}; } UIObject.prototype.merge = function (source, destination) { var key; for (key in source) { if (destination[key] === void 0) { destination[key] = source[key]; } else if (this.isObject(source[key])) { this.merge(source[key], destination[key]); } } }; return UIObject; })(); Foobar = (function () { __extends(Foobar, UIObject); function Foobar() { Foobar.__super__.constructor.call(this, "<h1/>", { html: "Foobar" }); } return Foobar; })();

    Read the article

  • unix process id

    - by swathi
    how to a Write a script that runs a 5 instances of a child process in the background (at a gap of 5 seconds) and do a continuous check to see if any of the child process is completed it starts another instance of the same process till the child process has executed 20 instances.

    Read the article

  • How to know if a std::list has been modified

    - by Nick
    I have this class: class C { public: C* parent; std::list<C> children; }; I can use this class in this way for example: C root; C child; root.children.push_back(child); // or other method of std::list (es: push_front, insert, ...) // Here child.parent is root // How can I set the parent of child? I want to do this work internally to my class without losing the functionality of std::list, is it possible?

    Read the article

  • Parsing String to TreeNode

    - by Krusu70
    Anyone have a good algorithm how to parse a String to TreeNode in Java? Let's say we have a string s which says how to build a TreeNode. A(B,C) means that A is the name (String) of TreeNode, B is child of A (Treenode), C is sibling of A (TreeNode). So if I call function with string A(B(D,E(F,G)),C) (just a example), then I get a TreeNode equals to: level A (String: name), B - Child (TreeNode), C - Sibling (TreeNode) level B (String: name), D - Child of B (TreeNode), E - Sibling of B (TreeNode) level E (String: name), F - Child of E (TreeNode), G - Sibling of E (TreeNode) The name may not be 1 letter, it could be like real name (many letters).

    Read the article

  • WPF UserControl event called only once?

    - by 742
    Hi Everyone, I need to bind two-way a property of a user control to a property of a containing user control. I also need to set a default value to the property from code in the child (cannot be done easily from XAML tags). If I call my code from the child constructor, the value is set in the parent but the change callback routine is not triggered (my understanding is that the parent doesn't yet exist at the time the child is created). My current workaround is to catch the Loaded event of the child and to call the code from the handler. Howver as Loaded is called more than once, I need to set a flag to set the property only the first time. I don't like this way, but I don't know if there is a single shot event that could be used, or if this can be done otherwise. Any feedback based on your experience?

    Read the article

  • What characters are widely supported in CSS class names?

    - by last-child
    As detailed here among other places, the only valid characters in a html/css class name is a-z, A-Z, 0-9, hyphen and underscore, and the first character should be a letter. But in practice, what characters are in fact supported by most browsers? More specifically, I wonder what browsers properly understands a slash (/) in a class name, and what browsers support class names starting with a number. I'm primarily interested in getting an answer for html rather than xhtml, in case there is a difference. Thank you.

    Read the article

  • flash button inside a button

    - by user164142
    I have a button containing 2 child buttons. I want to be able to keep the mouse over state active, when I rollover a child button. At present it fires mouse out when i rollover a child button, I suspect this is correct, but not what I want to happen. Any ideas how to get around this?

    Read the article

  • subviews show confused rotated state after a modal dialog is displayed

    - by deafgreatdane
    I've created a custom UIViewController that mimics the UISplitViewController. It manages two child view controllers that get displayed in the left & right body area while in landscape and hides the left to show in a popover when in portrait. It works fine, using the didRotateFromInterfaceOrientation: and willRotateToInterfaceOrientation: messages to reset the location and sizing of the child views. All the views and child controllers are loaded from a nib. This custom view controller is shown inside a UINavigationController. The trouble arises after one of the child view controllers uses presentModalViewController. If the device was rotated after the views were initialized (but before the modal controller is shown), after the modal dialog is dismissed, the left and/or body views will be re-rendered in a different rotation than they were before the modal dialog was changed. I'm wondering if folks have had a similar problem, and what the solution is. I'm sure sample code would be helpful, but it'll take a bunch of work to distill it into a runnable sample.

    Read the article

  • question about siftdown operation on heap

    - by davit-datuashvili
    i have following pseudo code which execute siftdown operation on heap array suppose is x void siftdown(int n) pre heap(2,n) && n>=0 post heap(1,n) i=1; loop /*invariant heap(1,n) except perhaps between i and it's (0,1,or 2) children*/ c=2*i; if (c>n) break; // c is left child of i if (c+1)<=n /* c+1 is rigth child of i if (x[c+1]<x[c]) c++ /* c is lesser child of i if (x[i]<=x[c]) break; swap(c,i) i=c; i have wrote following code is it correct? public class siftdown{ public static void main(String[]args){ int c; int n=9; int a[]=new int[]{19,100,17,2,7,3,36,1,25}; int i=1; while (i<n){ c=2*i; if (c>n) break; //c is the left child of i if (c+1<=n) //c+1 ir rigth child of i if (a[c+1]<a[c]) c++; if (a[i]<=a[c]) break; int t=a[c]; a[c]=a[i]; a[i]=t; i=c; } for (int j=0;j<a.length;j++){ System.out.println(a[j]); } } } // result is 19 2 17 1 7 3 36 100 25

    Read the article

  • Display Wordpress Category

    - by saorabh
    I want to display only the those parent category name and with their child category.. Example category AAAAA,BBBB,CCCCC,DDDDD Parent category AAAAA having child category a,b,c Parent category BBBB having child category x,y,z Now I want to display only (Result required) AAAAA a,b,c BBBB x,y,z Please help me...

    Read the article

  • Creating independent process!

    - by Neha
    I am trying to create a process from a service in C++. This new process is creating as a child process. I want to create an independent process and not a child process... I am using CreateProcess function for the same. Since the new process i create is a child process when i try to kill process tree at the service level it is killing the child process too... I dont want this to happen. I want the new process created to run independent of the service. Please advice on the same.. Thanks.. Code STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); // Start the child process. ZeroMemory( &pi, sizeof(pi) ); si.dwFlags = STARTF_USESHOWWINDOW; if(bRunOnWinLogonDesktop) { if(csDesktopName.empty()) si.lpDesktop = _T("winsta0\\default"); else _tcscpy(si.lpDesktop, csDesktopName.c_str()); } if(bHide) si.wShowWindow = SW_HIDE; /* maybe even SW_HIDE */ else si.wShowWindow = SW_SHOW; /* maybe even SW_HIDE */ TCHAR szCmdLine[512]; _tcscpy(szCmdLine, csCmdLine.c_str()); if( !CreateProcess( NULL, szCmdLine, NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi ) )

    Read the article

  • How to create a dynamic number of possibly children objects using partial views?

    - by NullReference
    I have a parent object that contains a property that is a list of children objects. I'd like to have it so that when the form loads to create the parent object a partial view is used to create the list of child objects. The problem is I have to idea how to have the list of children object populated. I can do one object ok, but a dynamic list of possible children is difficult. Any ideas? @Html.RenderPartial("_CreateChild", Model.Children); public class Parent { private List<Child> _list; public Guid Id { get; set; } public List<Child> Children { get { return _list; } set { _list = value; } } public Parent() { _list = new List<Child>(); } }

    Read the article

  • Sending floating point values between processes with pipes in C

    - by Alex
    Is there a standard way of sending floating point values from a child process to a parent process in C. I have a some calculations where I want to fork a process, then have the child do some busy work, the parent do something else, and then the child send its values (which are doubles) back to the parent (presumably through a pipe). Clearly the parent could parse the stream, but I'm just wondering if there's a cleaner way?

    Read the article

  • Any way to make a generic List where I can add a type AND a subtype?

    - by user383178
    I understand why I cannot do the following: private class Parent { }; private class Child extends Parent { }; private class GrandChild extends Child { }; public void wontCompile(List<? extends Parent> genericList, Child itemToAdd) { genericList.add(itemToAdd); } My question is there ANY practical way to have a typesafe List where you can call add(E) where E is known to be only a Parent or a Child? I vaguely remember some use of the "|" operator as used for wildcard bounds, but I cannot find it in the spec... Thanks!

    Read the article

  • Overriding vs Virtual

    - by anonymous
    What is the purpose of using the reserved word virtual in front of functions? If I want a child class to override a parent function, I just declare the same function such as "void draw(){}". class Parent{ public: void say(){ std::cout << "1"; }}; class Child : public Parent{public:void say(){ std::cout << "2"; } }; int main() { Child* a = new Child(); a->say(); return 0; } The output is 2. So again, why would the reserved word "virtual" be necessary in the header of say() ? Thanks a bunch.

    Read the article

  • MFC: 'Gluing' two windows/dialogs together

    - by John
    I'm trying to set something up so my main dialog has one or more child dialogs, and these are glued/docked to the outside of the main dialog - when the main dialog is minimised, the children are too, when main dialog moves, children move with it. I'd tried setting child dialogs as having main dialog CWnd as parent, with CHILD style. But then they get clipped by the parent's boundary. If I set them as POPUP, they can be outside but then don't move with the parent. I'm looking at putting an OnMove handler on the parent dialog, but is there something built-in? And, should child dialogs still be children of the main dialog... I assume they should? This is VS2005 (I think VS2008 has some related functionality so I mention this).

    Read the article

  • onUpdate in MySQL means?

    - by ajsie
    i know that if you create a foreign key on a field (parent_id) in a child table that refer to a parent table's primary key (id), then if this parent table is deleted the child class will be deleted as well if you set onDelete to cascade when creating the foreign key in the child class. but what happens if i set it to onUpdate = cascade?

    Read the article

  • Rails toggling closest submit button in a form with radio buttons

    - by Timothy
    I have a bunch of forms listed in Rails like such <% parent.children.some_named_scope.each do |child| %> <% form_for :parent, parent do |f| %> <% current_value = child.column_to_set %> <% child.possible_values_for_column_to_set.each do |value| %> <% f.fields_for :children, child, :child_index => child.id.to_s do |child_form| %> <%= child_form.label :column_to_set, value.to_s.titleize, :value => value %> <%= child_form.radio_button, :column_to_set, value, :type => 'radio' %> <% end %> <% end %> <%= f.submit "Submit", :disabled => true %> <% end %> <% end %> How do I set the submit button's disabled to false, dynamically, when it is not current_value and set it to true when it is while the user clicks radio buttons?

    Read the article

  • How to organise input for many classes

    - by Evl-ntnt
    I have one abstract class and many child classes. In child classes are from 2 to 20 members which must be filled by user. What the best way to do this using OOP? Make form for each child class? Or hide and unhide many input elements and labels? Is there some best way? I using WPF and C#

    Read the article

  • Get node parent of defined type using xpath

    - by IordanTanev
    Hi, i will give an example of the problem i have. My XML is like this <roor> <child Name = "child1"> <node> <element1>Value1</element1> <element2>Value2</element2> </node> </child> <child Name = "child2"> <element1>Value1</element1> <element2>Value2</element2> <element3>Value3</element3> </child> </root> I have xpath expression that returns all "element2" nodes. Then i want to for every node of type "element2" to find the node of type "child" that contains it. The problem is that between these two nodes there can be from 1 to n different nodes so i can't just use "..". Is there something like "//" that will look up instead of down Best Regards, Iordan

    Read the article

  • Capture subprocess output

    - by schneck
    Hi there, I learned that when executing commands in Python, I should use subprocess. What I'm trying to achieve is to encode a file via ffmpeg and observe the program output until the file is done. Ffmpeg logs the progress to stderr. If I try something like this: child = subprocess.Popen(command, shell=True, stderr=subprocess.PIPE) complete = False while not complete: stderr = child.communicate() # Get progress print "Progress here later" if child.poll() is not None: complete = True time.sleep(2) the programm does not continue after calling child.communicate() and waits for the command to complete. Is there any other way to follow the output?

    Read the article

  • Can I Have Polymorphic Containers With Value Semantics in C++11?

    - by John Dibling
    This is a sequel to a related post which asked the eternal question: Can I have polymorphic containers with value semantics in C++? The question was asked slightly incorrectly. It should have been more like: Can I have STL containers of a base type stored by-value in which the elements exhibit polymorphic behavior? If you are asking the question in terms of C++, the answer is "no." At some point, you will slice objects stored by-value. Now I ask the question again, but strictly in terms of C++11. With the changes to the language and the standard libraries, is it now possible to store polymorphic objects by value in an STL container? I'm well aware of the possibility of storing a smart pointer to the base class in the container -- this is not what I'm looking for, as I'm trying to construct objects on the stack without using new. Consider if you will (from the linked post) as basic C++ example: #include <iostream> using namespace std; class Parent { public: Parent() : parent_mem(1) {} virtual void write() { cout << "Parent: " << parent_mem << endl; } int parent_mem; }; class Child : public Parent { public: Child() : child_mem(2) { parent_mem = 2; } void write() { cout << "Child: " << parent_mem << ", " << child_mem << endl; } int child_mem; }; int main(int, char**) { // I can have a polymorphic container with pointer semantics vector<Parent*> pointerVec; pointerVec.push_back(new Parent()); pointerVec.push_back(new Child()); pointerVec[0]->write(); pointerVec[1]->write(); // Output: // // Parent: 1 // Child: 2, 2 // But I can't do it with value semantics vector<Parent> valueVec; valueVec.push_back(Parent()); valueVec.push_back(Child()); // gets turned into a Parent object :( valueVec[0].write(); valueVec[1].write(); // Output: // // Parent: 1 // Parent: 2 }

    Read the article

  • OneToMany association updates instead of insert

    - by Shvalb
    I have an entity with one-to-many association to child entity. The child entity has 2 columns as PK and one of the column is FK to the parent table. mapping looks like this: @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER ) @JoinColumn(name="USER_RESULT_SEQUENCES.USER_RESULT_ID", referencedColumnName="USER_RESULT_ID", unique=true, insertable=true, updatable=false) private List<UserResultSequence> sequences; I create an instance of parent and add children instances to list and then try to save it to DB. If child table is empty it inserts all children and it works perfectly. if the child table is not empty it updates existing rows! I don't know why it updates instead of inserts, any ideas why this might happen?? Thank you!

    Read the article

< Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >