Search Results

Search found 24043 results on 962 pages for 'private methods'.

Page 73/962 | < Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >

  • How to call a method from another class that's been instantiated within the current class

    - by Pavan
    my screen has a few views like such __________________ | _____ | | | | | //viewX is a video screen | | | | | viewX | vY | | //viewY is a custom uiview i created. | |____| | //it contains a method which i would like to call that toggles |_________________| //the hidden property of this view. and when it hides, a little | | //button is replaced no the top right corner on top of viewX | viewZ | //the video layer | | |_________________| //viewZ is a view containing many square views - thumbnails. my question is, i dont know how to register for touch events so that it recognises any touch event on no matter which view the user touches the screen.. atm im handling the touch events for each view inside it. so all works well... however what im trying to do is that when the user taps anywhere else on the screen but on viewY, viewY should dissapear by calling that method in the viewY class. this viewY class is instantiated and has no xib file attached to it. the uiview is created progammatically in the viewY class. this whole class for viewY behviour is instantiated in viewX - the video view. my boss says add delegates.. although i have now clue how to do that... any help? is there anyway i can just make it really simple and be able to say REMOVE VIEW no matter which class im calling from? Also ive seen other people achieve this by using these funky arrows - ... <- etc.. although im not sure if thats what i need or how to implement such a thing. ah i think ive made my question quite complicated but i really mean it to be a simple one, and know it can be done in an easy way!

    Read the article

  • How to use a method with more than one parameters to create custom buttons

    - by iphonix
    I am repeating my codes few times to create custom buttons, I am trying to create a method and create all my required buttons just by called that method and using two parameters, btnTitle and btnAction. My Codes for the method -(void) addnewButton:(NSString *) btnTitle withAction:UIAction btnAction; { // Add a custom edit navigation button editButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString((btnTitle), @"") style:UIBarButtonItemStyleBordered target:self action:@selector(btnAction)] autorelease]; self.navigationItem.rightBarButtonItem = editButton; } Now how shall I call this method to create a button?

    Read the article

  • How can I take any function as input for my Scala wrapper method?

    - by pr1001
    Let's say I want to make a little wrapper along the lines of: def wrapper(f: (Any) => Any): Any = { println("Executing now") val res = f println("Execution finished") res } wrapper { println("2") } Does this make sense? My wrapper method is obviously wrong, but I think the spirit of what I want to do is possible. Am I right in thinking so? If so, what's the solution? Thanks!

    Read the article

  • loading method based on URL

    - by steeped
    I am trying to build a small mvc-based application. How do I call a method in a class based on a query string? For example, the $_GET query string is being set as load_master_form http://www.domain.com/settings/load_master_form And to call the method within the settings class, I am doing: function __construct(){ $this->{$_GET['method']}(); } But obviously that doesn't work - it just isn't possible to load a method like that. So how would it be done?

    Read the article

  • Create Extension Method to Produce Open & Closing Tags like Html.BeginForm()

    - by DaveDev
    Hi Guys I wonder if it's possible to create an extension method which has functionality & behaviour similar to Html.BeginForm(), in that it would generate a complete Html tag, and I could specificy its contents inside <% { & } %> tags. For example, I could have a view like: <% using(Html.BeginDiv("divId")) %> <% { %> <!-- Form content goes here --> <% } %> This capability would be very useful in the context of the functionality I'm trying to produce with the example in this question This would give me the ability to create containers for the types that I'll be <% var myType = new MyType(123, 234); %> <% var tag = new TagBuilder("div"); %> <% using(Html.BeginDiv<MyType>(myType, tag) %> <% { %> <!-- controls used for the configuration of MyType --> <!-- represented in the context of a HTML element, e.g.: --> <div class="MyType" prop1="123" prop2="234"> <!-- add a select here --> <!-- add a radio control here --> <!-- whatever, it represents elements in the context of their type --> </div> <% } %> I realise this will produce invalid XHTML, but I think there could be other benefits that outweigh this, especially since this project doesn't require that the XHTML validate to the W3C standards. Thanks Dave

    Read the article

  • How to specify generic method type parameters partly

    - by DNNX
    I have an extension method like below: public static T GetValueAs<T, R>(this IDictionary<string, R> dictionary, string fieldName) where T : R { R value; if (!dictionary.TryGetValue(fieldName, out value)) return default(T); return (T)value; } Currently, I can use it in the following way: var dictionary = new Dictionary<string, object(); //... var list = dictionary.GetValueAs<List<int, object("A"); // this may throw ClassCastException - this is expected behavior; It works pretty fine, but the second type parameter is really annoying. Is it possible in C# 4.0 rewrite GetValueAs is such a way that the method will still be applicable to different types of string-keyed dictionaries AND there will be no need to specify second type parameter in the calling code, i.e. use var list = dictionary.GetValueAs<List<int("A"); or at least something like var list = dictionary.GetValueAs<List<int, ?("A"); instead of var list = dictionary.GetValueAs<List<int, object("A");

    Read the article

  • Which kind of method signature do you prefer and why?

    - by devoured elysium
    Ok, this is probably highly subjective but here it comes: Let's assume I'm writing a method that will take a printscreen of some region of the screen. Which method signature would you prefer and why? Bitmap DoPrintScreen(int x, int y, int width, int height); Bitmap DoPrintScreen(Rectangle rect); Bitmap DoPrintScreen(Point point, Size size); Other Why? I keep seeing myself repeatedly implementing both 1) and 2) (redirecting one of them to the other) but I end up usually just using one of them, so there really is no point in having both. I can't decide which would be better. Maybe I should use the signature that looks the most with the method I'll be calling to make the printscreen?

    Read the article

  • C++. What is a subprogram and method?

    - by xbonez
    I have a CPP HW to be done. One question is: 1) Write a subprogram (not a method) void promptForMovie(Movie & myMovie) that ..... 2) Write a method void output(ostream & out); that .... My question is what exactly is a subprogram and a method? Which one of them means a function, and what does the other mean? Thank you

    Read the article

  • What elegant method callback design should be used ?

    - by ereOn
    Hi, I'm surprised this question wasn't asked before on SO (well, at least I couldn't find it). Have you ever designed a method-callback pattern (something like a "pointer" to a class method) in C++ and, if so, how did you do it ? I know a method is just a regular function with some hidden this parameter to serve as a context and I have a pretty simple design in mind. However, since things are often more complex than they seem to, I wonder how our C++ gurus would implement this, preferably in an elegant and standard way. All suggestions are welcome !

    Read the article

  • Understanding the singleton class when aliasing a instance method

    - by Backo
    I am using Ruby 1.9.2 and the Ruby on Rails v3.2.2 gem. I am trying to learn Metaprogramming "the right way" and at this time I am aliasing an instance method in the included do ... end block provided by the RoR ActiveSupport::Concern module: module MyModule extend ActiveSupport::Concern included do # Builds the instance method name. my_method_name = build_method_name.to_sym # => :my_method # Defines the :my_method instance method in the including class of MyModule. define_singleton_method(my_method_name) do |*args| # ... end # Aliases the :my_method instance method in the including class of MyModule. singleton_class = class << self; self end singleton_class.send(:alias_method, :my_new_method, my_method_name) end end "Newbiely" speaking, with a search on the Web I came up with the singleton_class = class << self; self end statement and I used that (instead of the class << self ... end block) in order to scope the my_method_name variable, making the aliasing generated dynamically. I would like to understand exactly why and how the singleton_class works in the above code and if there is a better way (maybe, a more maintainable and performant one) to implement the same (aliasing, defining the singleton method and so on), but "the right way" since I think it isn't so.

    Read the article

  • how to access method variables from within an anonomous function in javascript

    - by Hussain
    I'm writing a small ajax class for personal use. In the class, I have a "post" method for sending post requests. The post method has a callback parameter. In the onreadystatechange propperty, I need to call the callback method. Something like this: this.requestObject.onreadystatechange = function() { callback(this.responseText); } However, I can't access the callback variable from within the anonomous function. How can I bring the callback variable into the scope of the onreadystatechange anonomous function?

    Read the article

  • Can you have an extension method on a type instead of on an instance of a type?

    - by SLC
    I can have an extension method like this: DateTime d = new DateTime(); d = d.GetRandomDate(); GetRandomDate is my extension method. However the above doesn't make much sense. What would be better is: DateTime d = DateTime.GetRandomDate(); However, I don't know how to do this. An extension method created as: public static DateTime GetRandomDate(this System.DateTime dt) will only add the GetRandomDate() in the first example above, not the second one. Is there a way to achieve the desired behaviour?

    Read the article

  • when to make a method static

    - by Don
    Hi, I'd like to know how people decide whether to define a method as static. I'm aware that a method can only be defined as static if it doesn't require access to instance fields. So lets say we have a method that does not access instance fields, do you always define such a method as static, or only if you need to call it statically (without a reference to an instance). Perhaps another way of asking the same question, is whether you use static or non-static as the default? Thanks, Don

    Read the article

  • C# Extension Method for String Data Type

    - by Jimbo
    My web application deals with strings that need to be converted to numbers alot - users often put commas, currency symbols etc. in these fields so what I want to do is create a string extension method that cleans the field up and converts it to a decimal. For example: decimal myNumber = "$1,250.85".ToDecimal(); Can anyone help with this? Thanks!

    Read the article

  • Line by Line explanation of "Javascript: Good Parts" example?

    - by Matrym
    I'm reading "Javascript: The Good Parts" and am totally baffled by what's really going on here. A more detailed and/or simplified explanation would be greatly appreciated. // BAD EXAMPLE // Make a function that assigns event handler functions to an array of nodes the wrong way. // When you click on a node, an alert box is supposed to display the ordinal of the node. // But it always displays the number of nodes instead. var add_the_handlers = function (nodes) { var i; for (i = 0; i < nodes.length; i += 1) { nodes[i].onclick = function (e) { alert(i); } } }; // END BAD EXAMPLE The add_the_handlers function was intended to give each handler a unique number (i). It fails because the handler functions are bound to the variable i, not the value of the variable i at the time the function was made: // BETTER EXAMPLE // Make a function that assigns event handler functions to an array of nodes the right way. // When you click on a node, an alert box will display the ordinal of the node. var add_the_handlers = function (nodes) { var i; for (i = 0; i < nodes.length; i += 1) { nodes[i].onclick = function (i) { return function (e) { alert(i); }; }(i); } }; Now, instead of assigning a function to onclick, we define a function and immediately invoke it, passing in i. That function will return an event handler function that is bound to the value of i that was passed in, not to the i defined in add_the_handlers. That returned function is assigned to onclick.

    Read the article

  • WebView not responding when called from a method

    - by AragornSG
    I have an app with tabbar and webview. I'm trying to make the app come back to default url each time user taps the bar. Right now I'm intercepting taps and launching a method, however it's not affecting my webview. The same syntax for calling webview from awakeFromNib works, so I don't have a clue what's up. I suspect it's something to do with how I call the method, but I don't know what. Here is the code: #import "SecondViewController.h" @implementation SecondViewController - (void)awakeFromNib { NSString *loadURL = [NSString stringWithFormat:@"http://pageurl"]; // [secondView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadURL]]]; SecondViewController *ptr = [[SecondViewController alloc] init]; [ptr goToPage]; } - (void) goToPage { NSLog(@"go to page"); NSString *newURL = [NSString stringWithFormat:@"http://pageurl"]; [secondView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:newURL]]]; } Thanks fot your help!

    Read the article

  • Behaviour to simulate an enum implementing an interface

    - by fearofawhackplanet
    Say I have an enum something like: enum OrderStatus { AwaitingAuthorization, InProduction, AwaitingDespatch } I've also created an extension method on my enum to tidy up the displayed values in the UI, so I have something like: public static string ToDisplayString(this OrderStatus status) { switch (status) { case Status.AwaitingAuthorization: return "Awaiting Authorization"; case Status.InProduction: return "Item in Production"; ... etc } } Inspired by the excellent post here, I want to bind my enums to a SelectList with an extension method: public static SelectList ToSelectList<TEnum>(this TEnum enumObj) however, to use the DisplayString values in the UI drop down I'd need to add a constraint along the lines of : where TEnum has extension ToDisplayString Obviously none of this is going to work at all with the current approach, unless there's some clever trick I don't know about. Does anyone have any ideas about how I might be able to implement something like this?

    Read the article

  • Logic: Best way to sample & count bytes of a 100MB+ file

    - by Jami
    Let's say I have this 170mb file (roughly 180 million bytes). What I need to do is to create a table that lists: all 4096 byte combinations found [column 'bytes'], and the number of times each byte combination appeared in it [column 'occurrences'] Assume two things: I can save data very fast, but I can update my saved data very slow. How should I sample the file and save the needed information? Here're some suggestions that are (extremely) slow: Go through each 4096 byte combinations in the file, save each data, but search the table first for existing combinations and update it's values. this is unbelievably slow Go through each 4096 byte combinations in the file, save until 1 million rows of data in a temporary table. Go through that table and fix the entries (combine repeating byte combinations), then copy to the big table. Repeat going through another 1 million rows of data and repeat the process. this is faster by a bit, but still unbelievably slow This is kind of like taking the statistics of the file. NOTE: I know that sampling the file can generate tons of data (around 22Gb from experience), and I know that any solution posted would take a bit of time to finish. I need the most efficient saving process

    Read the article

  • using empty on inaccessible object with __isset and __get

    - by David
    <?php class Magic_Methods { protected $meta; public function __construct() { $this->meta = (object) array( 'test' => 1 ); } public function __isset($name) { echo "pass isset {$name} \n"; return isset($this->$name); } public function __get($name) { echo "pass get {$name} \n"; return $this->$name; } } $mm = new Magic_Methods(); $meta = empty($mm->meta->notExisting); var_dump($meta); echo "||\n"; $meta = empty($mm->meta); var_dump($meta); The snippet above does not work as expected for me. Why would the first empty() ommit the __isset? I get this: pass get meta bool(true) || pass isset meta pass get meta bool(false) I would expected identical results or another pass at the __isset, but not a direct call to __get. Or am I missing something here?

    Read the article

  • Is there anything wrong with a class with all static methods?

    - by MatthewMartin
    I'm doing code review and came across a class that uses all static methods. The entrance method takes several arguments and then starts calling the other static methods passing along all or some of the arguments the entrance method received. It isn't like a Math class with largely unrelated utility functions. In my own normal programming, I rarely write methods where Resharper pops and says "this could be a static method", when I do, they tend to be mindless utility methods. Is there anything wrong with this pattern? Is this just a matter of personal choice if the state of a class is held in fields and properties or passed around amongst static methods using arguments?

    Read the article

  • c# creating a database query METHOD

    - by Sinaesthetic
    I'm not sure if im delluded but what I would like to do is create a method that will return the results of a query, so that i can reuse the connection code. As i understand it, a query returns an object but how do i pass that object back? I want to send the query into the method as a string argument, and have it return the results so that I can use them. Here's what i have which was a stab in the dark, it obviously doesn't work. This example is me trying to populate a listbox with the results of a query; the sheet name is Employees and the field/column is name. The error i get is "Complex DataBinding accepts as a data source either an IList or an IListSource.". any ideas? public Form1() { InitializeComponent(); openFileDialog1.ShowDialog(); openedFile = openFileDialog1.FileName; lbxEmployeeNames.DataSource = Query("Select [name] FROM [Employees$]"); } public object Query(string sql) { System.Data.OleDb.OleDbConnection MyConnection; System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand(); string connectionPath; //build connection string connectionPath = "provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + openedFile + "';Extended Properties=Excel 8.0;"; MyConnection = new System.Data.OleDb.OleDbConnection(connectionPath); MyConnection.Open(); myCommand.Connection = MyConnection; myCommand.CommandText = sql; return myCommand.ExecuteNonQuery(); }

    Read the article

  • Importing specific ( in my case - Themes.ThemesService.ThemesEnabled ) function / procedure in runet

    - by HX_unbanned
    Hi again :) I think subject tells everything ... I need this method only. No need to waste about 6Mb of included unit if only thing I need is one method from that unit ( Themes ) ... I was thinking of UxTheme unit, but it did not contain proper function. What Windows DLL do I need to import and what API function this method stands for? Thanks. P.S. Question is intended to cover not only this particular method, but others too as I will need to do same in MSXML and MM units ...

    Read the article

< Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >