Search Results

Search found 2441 results on 98 pages for 'delegate'.

Page 7/98 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Move UIImageView inside accelerometer delegate

    - by ghiboz
    Hi all! my view controller is set to accept accelerometer delegate, and if I put the accelerometer value inside a label works... after I tried to move an UIImageView into my ViewController and nothing happens (the image is putted into the view from the interface builder... (i try to move the image using the frame origin properties) thanks in advance...

    Read the article

  • PropertyInfo from Delegate

    - by Paul Hatcherian
    Is there a simple way to get the PropertyInfo for a property in a delegate, assuming it is a simple property seletor? Example: var propertyInfo = Method<MyClass,int>(s => s.Property); ... PropertyInfo Method(Func<T1,T2> selector) { // What goes here? }

    Read the article

  • Core-Data Can't pass managedObjectContext from app delegate to view controller

    - by yahuie
    I'm making a core-data application that is view based. I can create the managedObjectContext and 'use' it in the app delegate, but can not pass it to the mainviewcontroller. Probably something simple, but I can't find the problem after looking for quite a while. The managedObjectModel is nil in the mainviewcontroller. The log and error is here: 2010-06-02 11:01:10.504 TestCoreData[404:207] Could not make MOC in MainViewController implementation. 2010-06-02 11:01:10.505 TestCoreData[404:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Shelf'' 2010-06-02 11:01:10.506 TestCoreData[404:207] Stack: ( 30864475, 2452296969, 28852395, 12038, 3217218, 10258, 2700679, 2738614, 2726708, 2709119, 2736225, 38960473, 30649216, 30645320, 2702869, 2740143, 9704, 9558 ) (gdb) Code for app delegate here: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; self.mainViewController = aController; [aController release]; NSLog(@"before did finish launching"); if (self.managedObjectContext == nil) { NSLog(@"Could not make MOC in TestCoreDataAppDelegate implementation."); } //Just to see if I can access the here. NSFetchRequest* request = [[NSFetchRequest alloc] init]; NSEntityDescription* entity = [NSEntityDescription entityForName:@"Shelf" inManagedObjectContext:self.managedObjectContext]; [request setEntity:entity]; if (!entity) { NSLog(@"No Entity in TestCoreDataAppDelegate didfinishlaunching"); } NSLog(@"passed did finish launching"); NSManagedObjectContext *context = [self managedObjectContext]; self.mainViewController.view.frame = [UIScreen mainScreen].applicationFrame; self.mainViewController.managedObjectContext = context; [context release]; [window addSubview:[mainViewController view]]; [window makeKeyAndVisible]; return YES; } Code in MainViewController here: @implementation MainViewController @synthesize managedObjectContext; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; if (self.managedObjectContext == nil) { NSLog(@"Could not make MOC in MainViewController implementation."); } NSFetchRequest* request = [[NSFetchRequest alloc] init]; NSEntityDescription* entity = [NSEntityDescription entityForName:@"Shelf" inManagedObjectContext:self.managedObjectContext]; [request setEntity:entity]; } Thanks.

    Read the article

  • Wierd typeloadexception "Bad flags on delegate constructor."

    - by Marcus
    Hi, Anybody seen this exception before, Google doesn't have a single post regarding the exception. The code that raises the error is a simple add. Items.Add(item); System.TypeLoadException: Bad flags on delegate constructor. at System.Windows.Forms.ListView.Sort() at System.Windows.Forms.ListView.InsertItems(Int32 displayIndex, ListViewItem[] items, Boolean checkHosting) at System.Windows.Forms.ListView.ListViewNativeItemCollection.Add(ListViewItem value) at System.Windows.Forms.ListView.ListViewItemCollection.Add(ListViewItem value)

    Read the article

  • triggering an event with jQuery live or delegate

    - by patrick
    I'd like to attach a handler to an element using either jQuery live() or delegate(). Looking at the docs I see I can attach the handler for a custom event. Is this possible for either of these jQuery functions to also trigger the handler? Basically I want to attach the handler function and run call it once. Thank you for any help.

    Read the article

  • iPhone - extending a class delegate

    - by Digital Robot
    OK, I know how to create a class extension, using something like that: on .h @interface UIButton (myExtensionName) // my extended methods @end and then on .m @implementation UIButton (myExtensionName) // my implementations @end But how do I declare the extended delegates I may create? If this was a normal class I would do @protocol myExtensionName <NSObject> // my delegate declarations @end but how do I do that on a class extension? thanks

    Read the article

  • C# delegate to Java conversion

    - by Derek
    I am in the process of converting some code from C# to Java. I have never used C# before, but it has been pretty easy up to this point. I have a line that looks like this in the C# file: coverage.createMethod = delegate (Gridpoint gp){ //Some method stuff in here, with a return objecct } What exactly is this trying to do? It seems a little bit like an inline class but I am not sure how to go about converting htis to java

    Read the article

  • cellForRowAtIndexPath not being called, but rowsInSections is and it's delegate is set

    - by Jhorra
    I searched around prior to posting this and made sure I hadn't missed anything obvious, though I have a feeling I am missing something basic. I'm using this as a sidebar navigation view. I tried making them static cells and pre-populating them, but they were blank that way as well. When I do it this way I can see everything gets called except that. I've tried deleting it and re-adding it. #import "acxSideBarController.h" @interface acxSideBarController () @end @implementation acxSideBarController @synthesize sidebarDelegate = _sidebarDelegate; - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; if ([self.sidebarDelegate respondsToSelector:@selector(lastSelectedIndexPathForSidebarViewController:)]) { NSIndexPath *indexPath = 0; [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; } self.tableView.backgroundColor = [UIColor underPageBackgroundColor]; self.tableView.dataSource = self; self.tableView.delegate = self; } - (void)viewDidUnload { [super viewDidUnload]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if(section == 0) return 2; else if(section == 1) return 1; else return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"linkCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } NSString *name = @""; if(indexPath.section == 1) name = @"Inbox"; else if(indexPath.section == 2) name = @"Logout"; else { if(indexPath.row == 0) name = @"Roster"; else if(indexPath.row == 1) name = @"Environmental Variables"; } cell.textLabel.text = name; cell.textLabel.textColor = [UIColor darkTextColor]; return cell; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if(section == 0) return @"Students"; else if(section == 1) return @"Communication"; else return @" "; } #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (self.sidebarDelegate) { [self.sidebarDelegate acxSideBarController:self atIndexPath:indexPath]; } } @end If it's helpful here's the header file #import <UIKit/UIKit.h> @protocol acxSideBarControllerDelegate; @interface acxSideBarController : UITableViewController @property (nonatomic, assign) id <acxSideBarControllerDelegate> sidebarDelegate; @end @protocol acxSideBarControllerDelegate <NSObject> - (void)acxSideBarController:(acxSideBarController *)acxSideBarController atIndexPath:(NSIndexPath *)indexPath; @optional - (NSIndexPath *)lastSelectedIndexPathForacxSideBarController:(acxSideBarController *)acxSideBarController; @end

    Read the article

  • UIStoryboard load from app delegate

    - by Alessandro
    I am trying to load a UIStoryboard from the app delegate .m in this way: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]]; UIViewController *vc =[storybord instantiateInitialViewController]; [self.window addSubview:vc.view]; return YES; } What is the problem with this code?? any idea?

    Read the article

  • c# Delegate and Dispatcher problem

    - by Tan
    Hi i get this error when trying this ERROR method name expected. How should i do to correct the problem thanks for help delegate void DelegateFillList(DeliveryDoc[] deliveryDocs); private void FillListViewAssignment(DeliveryDoc[] docs) { if(lvMyAssignments.Dispatcher.CheckAccess()) { lvMyAssignments.ItemsSource = docs; lvAllOngoingAssignments.ItemsSource = docs; if(m_tempDeliveryDocs != null) { txtblockHandOverCount.Text = m_tempDeliveryDocs.Length.ToString(); } } else { lvMyAssignments.Dispatcher.BeginInvoke(new DelegateFillList(FillListViewAssignment(docs)), null); } }

    Read the article

  • Main point of Application Delegate class

    - by ahmet732
    What's the main point behind putting variables and method signatures inside ApplicationDelegate.h in Objective-C ? By doing this, all those methods and variables are seen by another view controller classes? Is that the point? And also: is there only one application delegate class inside each project?

    Read the article

  • Use pushViewController within app Delegate

    - by FMT
    Hi there i want to use this code within the app delegate ChatController *chatController = [[AppDelegate appDelegate] instantiateViewControllerWithIdentifier:@"GroupController"]; chatController.targetUserid = userid; [self.navigationController pushViewController:groupChatController animated:YES]; how can i push viewcontroller from appdelegate i mean make the above code work cuz self.navigationcontroller doesnt work :$

    Read the article

  • C#, Delegates and LINQ

    - by JustinGreenwood
    One of the topics many junior programmers struggle with is delegates. And today, anonymous delegates and lambda expressions are profuse in .net APIs.  To help some VB programmers adapt to C# and the many equivalent flavors of delegates, I walked through some simple samples to show them the different flavors of delegates. using System; using System.Collections.Generic; using System.Linq; namespace DelegateExample { class Program { public delegate string ProcessStringDelegate(string data); public static string ReverseStringStaticMethod(string data) { return new String(data.Reverse().ToArray()); } static void Main(string[] args) { var stringDelegates = new List<ProcessStringDelegate> { //========================================================== // Declare a new delegate instance and pass the name of the method in new ProcessStringDelegate(ReverseStringStaticMethod), //========================================================== // A shortcut is to just and pass the name of the method in ReverseStringStaticMethod, //========================================================== // You can create an anonymous delegate also delegate (string inputString) //Scramble { var outString = inputString; if (!string.IsNullOrWhiteSpace(inputString)) { var rand = new Random(); var chs = inputString.ToCharArray(); for (int i = 0; i < inputString.Length * 3; i++) { int x = rand.Next(chs.Length), y = rand.Next(chs.Length); char c = chs[x]; chs[x] = chs[y]; chs[y] = c; } outString = new string(chs); } return outString; }, //========================================================== // yet another syntax would be the lambda expression syntax inputString => { // ROT13 var array = inputString.ToCharArray(); for (int i = 0; i < array.Length; i++) { int n = (int)array[i]; n += (n >= 'a' && n <= 'z') ? ((n > 'm') ? 13 : -13) : ((n >= 'A' && n <= 'Z') ? ((n > 'M') ? 13 : -13) : 0); array[i] = (char)n; } return new string(array); } //========================================================== }; // Display the results of the delegate calls var stringToTransform = "Welcome to the jungle!"; System.Console.ForegroundColor = ConsoleColor.Cyan; System.Console.Write("String to Process: "); System.Console.ForegroundColor = ConsoleColor.Yellow; System.Console.WriteLine(stringToTransform); stringDelegates.ForEach(delegatePointer => { System.Console.WriteLine(); System.Console.ForegroundColor = ConsoleColor.Cyan; System.Console.Write("Delegate Method Name: "); System.Console.ForegroundColor = ConsoleColor.Magenta; System.Console.WriteLine(delegatePointer.Method.Name); System.Console.ForegroundColor = ConsoleColor.Cyan; System.Console.Write("Delegate Result: "); System.Console.ForegroundColor = ConsoleColor.White; System.Console.WriteLine(delegatePointer(stringToTransform)); }); System.Console.ReadKey(); } } } The output of the program is below: String to Process: Welcome to the jungle! Delegate Method Name: ReverseStringStaticMethod Delegate Result: !elgnuj eht ot emocleW Delegate Method Name: ReverseStringStaticMethod Delegate Result: !elgnuj eht ot emocleW Delegate Method Name: b__1 Delegate Result: cg ljotWotem!le une eh Delegate Method Name: b__2 Delegate Result: dX_V|`X ?| ?[X ]?{Z_X!

    Read the article

  • The sign of a true manager is delegation (C# style)

    - by MarkPearl
    Today I thought I would write a bit about delegates in C#. Up till recently I have managed to side step any real understanding of what delegates do and why they are useful – I mean, I know roughly what they do and have used them a lot, but I have never really got down dirty with them and mucked about. Recently however with my renewed interest in Silverlight delegates came up again as a possible solution to a particular problem, and suddenly I found myself opening a bland little console application to just see exactly how far I could take delegates with my limited knowledge. So, let’s first look at the MSDN definition of delegates… A delegate declaration defines a reference type that can be used to encapsulate a method with a specific signature. A delegate instance encapsulates a static or an instance method. Delegates are roughly similar to function pointers in C++; however, delegates are type-safe and secure. Well, don’t you love MSDN for such a useful definition. I must give it credit though… later on it really explains it a bit better by saying “A delegate lets you pass a function as a parameter. The type safety of delegates requires the function you pass as a delegate to have the same signature as the delegate declaration.” A little more reading up on delegates mentions that delegates are similar to interfaces in that they enable the separation of specification and implementation. A delegate declares a single method, while an interface declares a group of methods. So enough reading - lets look at some code and see a basic example of a delegate… Let’s assume we have a console application with a simple delegate declared called AdjustValue like below… class Program { private delegate int AdjustValue(int val); static void Main(string[] args) { } } In a sense, all we have said is that we will be creating one or more methods that follow the same pattern as AdjustValue – i.e. they will take one input value of type int and return an integer. We could then expand our code to have various methods that match the structure of our delegate AdjustValue (remember the structure is int xxx (int xxx)) class Program { private delegate int AdjustValue(int val); private static int Dbl(int val) { return val * 2; } private static int AlwaysOne(int val) { return 1; } static void Main(string[] args) { } }  Above I have expanded my project to have two methods, one called Dbl and the other AlwaysOne. Dbl always returns double the input val and AlwaysOne always returns 1. I could now declare a variable and assign it to be one of those functions, like the following… class Program { private delegate int AdjustValue(int val); private static int Dbl(int val) { return val * 2; } private static int AlwaysOne(int val) { return 1; } static void Main(string[] args) { AdjustValue myDelegate; myDelegate = Dbl; Console.WriteLine(myDelegate(1).ToString()); Console.ReadLine(); } } In this instance I have declared an instance of the AdjustValue delegate called myDelegate; I have then told myDelegate to point to the method Dbl, and then called myDelegate(1). What would the result be? Yes, in this instance it would be exactly the same as me calling the following code… static void Main(string[] args) { Console.WriteLine(Dbl(1).ToString()); Console.ReadLine(); }   So why all the extra work for delegates when we could just do what we did above and call the method directly? Well… that separation of specification to implementation comes to mind. So, this all seems pretty simple. Let’s take a slightly more complicated variation to the console application. Assume that my project is the same as the one previously except that my main method is adjusted as follows… static void Main(string[] args) { AdjustValue myDelegate; myDelegate = Dbl; myDelegate = AlwaysOne; Console.WriteLine(myDelegate(1).ToString()); Console.ReadLine(); } What would happen in this scenario? Quite simply “1” would be written to the console, the reason being that myDelegate was last pointing to the AlwaysOne method before it was called. Make sense? In a way, the myDelegate is a variable method that can be swapped and changed when needed. Let’s make the code a little more confusing by using a delegate in the declaration of another delegate as shown below… class Program { private delegate int AdjustValue(InputValue val); private delegate int InputValue(); private static int Dbl(InputValue val) { return val()*2; } private static int GetInputVal() { Console.WriteLine("Enter a whole number : "); return Convert.ToInt32(Console.ReadLine()); } static void Main(string[] args) { AdjustValue myDelegate; myDelegate = Dbl; Console.WriteLine(myDelegate(GetInputVal).ToString()); Console.ReadLine(); } }   Now it gets really interesting because it looks like we have passed a method into a function in the main method by declaring… Console.WriteLine(myDelegate(GetInputVal).ToString()); So, what it the output? Well, try take a guess on what will happen – then copy the code and see if you got it right. Well that brings me to the end of this short explanation of Delegates. Hopefully it made sense!

    Read the article

  • Iphone: TabView + TableView

    - by OneTrickPonySoft
    I think I'm missing something simple, but I can't figure out exactly what it is. I'm trying to set up an App with a UITabViewController, and one of the Tabs will have a UITableView and UISearchBar (but no Navigation Controller). I set up the UITabViewController with all the tabs in interface builder, and the views are in their own xib files. The xib file for the tab with the UITableView is set up and connected as follows. Stuff in the browser: File's owner (Class is my custom class that is a child of UITableViewController) view - View View (class UIView, reference view - File's owner) contains: UITableView (if i try and set references to the data source / delegate, the app breaks) UISearchBar (unconfigured at the moment) This setup displays all the items and doesn't lock up, but I can't assign a DataSource without it crashing when i try and load the tab with the UITableView. What should I do to get data into this table, either in IB or code? My ideas are as follows: Implement custom UITableView class, hook up to table view in IB or to custom tableviewcontroller in Xcode. Pound head or laptop against the wall until it works. Update: Here's the error the simulator pushes to the console when I connect the Tableview's data source and delegate to File Owner (who's class is my custom tableviewcontroller). 2/14/09 6:59:12 PM TabBarWillbeRight[33172] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x523760'

    Read the article

  • Pass an Event as parameter

    - by dkson
    I have a class which bundles events and registers controls to easily register/unregister them, it's basically used this way: Private Sub MyFocusHandler(ByVal sender As Object, ...) ... End Sub ... Dim b1 = new MyTextBox() Dim b2 = new MyTextBox() .... 'Lot of Controls' Dim cr = new ControlRegistration() cr.RegisterControl(b1) cr.RegisterControl(b2) .... 'Register a lot of controls' cr.RegisterEvent("Focus",New EventHandler(AddressOf MyFocusHandler)) cr.RegisterEvent("Validate",New EventHandler(AddressOf MyValidateHandler)) So I don't have to add the handlers manually for each control. The ControlRegistration-Class will cycle through the list of registered controls and check if a control has a registered event and then attach the eventhandler, something like: ... For Each control in contols Dim ev_info As Reflection.EventInfo = _ control.GetType().GetEvent(.GetType().GetEvent(event_name)) If Not (ev_info Is Nothing) Then ev_info.AddEventHandler ... ... My problem is that i am identifying the event by a string Public Sub RegisterEvent(ByVal eventName As String, ByVal handler As [Delegate]) ... ... cr.RegisterEvent("Focus",New EventHandler(AddressOf MyFocusHandler)) I don't want to depend on the name of the event, since it is possibly that the name changes, and then things will break up. Is there a way I can do this like: Public Sub RegisterEvent(ByVal theEvent As ???, ByVal handler As [Delegate]) ... ... cr.RegisterEvent(IMyControl.MyEvent,New EventHandler(AddressOf MyEventHandler)) I hope it is clear what I want to archive. Anybody any ideas? Thanks

    Read the article

  • Implementation of MVC with SQLite and NSURLConnection, use cases?

    - by user324723
    I'm interested in knowing how others have implemented/designed database & web services in their iphone app and how they simplified it for the entire application. My application is dependent on these services and I can't figure out a efficient way to use them together due to the (semi)complexity of my requirements. My past attempts on combining them haven't been completely successful or at least optimal in my mind. I'm building a database driven iphone app that uses a relational database in sqlite and consumes web services based on missing content or user interaction. Like this hasn't been done before...right? Since I am using a relational database - any web services consumed requires normalization, parsing the result and persisting it to the database before it can be displayed in a table view controller. The applications UI consists of nested(nav controller) table views where a user can select a cell and be taken to the next table view where it attempts to populate the table views data source from the database. If nothing exists in the database then it will send a request via web services to download its content, thus download - parse - persist - query - display. Since the user has the ability to request a refresh of this data it still requires the same process. Quickly describing what I've implemented and tried to run with - 1st attempt - Used a singleton web service class that handled sending web service requests, parsing the result and returning it to the table view controller via delegate protocols. Once the controller received that data it would then be responsible for persisting it to the database and re-returning the result. I didn't like the idea of only preventing the case where the app delegate selector doesn't exists(released) causing the app to crash. 2nd attempt - Used NSNotificationCenter for easy access to both database and web services but later realized it was more complex due to adding and removing observers per view(which isn't advised anyways).

    Read the article

  • Compiler warning "not found in protocol(s)" when using [[[UIApplication sharedApplication] delegate]

    - by DK Crame
    I have myClass instantiated by my appDelegate, I have another class, newClass instantiated by myClass. From the newClass instance, I want to access a property in the myClass instance that created it. I have done this by: [[[UIApplication sharedApplication].delegate myClass] property] This works, I can actually get the property but I get this warning from Xcode: warning: "-myClass" not found in protocols warning: no "-myClass" method found (messages without a matching signature will be assumed to return "id" and accept "..." as arguments) The newClass property has been correctly declared in the .h and .m files, it's properties have been set and it has been synthesized. It compiles and runs and I can actually get the property's value. Should I ignore the warning in Xcode? Is there a better way to access the myClass instance's property?

    Read the article

  • Setting an delegate for the UIDatePicker animation?

    - by james.ingham
    If I had a date picker within an action sheet and called the following line: [datePicker setDate:newDate animated:YES]; And then my app hides the action sheet the date picker is within, is there anyway to set up a animation delegate so that the user see's the animation of the date picker first and then hides the action sheet? I have done this with UIView's by calling: [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(METHOD)]; However I can not see anything like this for the date picker. Thanks in advanced - James

    Read the article

  • Dictionary with delegate or swith?

    - by Samvel Siradeghyan
    Hi, I am writting a parser, which call some functions dependent on some value. I can implement this logic with simple switch like this swith(some_val) { case 0: func0(); break; case 1: func1(); break; } or with delegates and dictinary like this delegate void some_delegate(); Dictinary some_dictinary = new Dictinary(); some_dictinary[0] = func0; some_dictinary[1] = func1; some_dictinary[some_value].Invoke(); Are this two metods equal and wich is prefered? Thanks.

    Read the article

  • Dictionary with delegate or switch?

    - by Samvel Siradeghyan
    Hi, I am writing a parser, which call some functions dependent on some value. I can implement this logic with simple switch like this switch(some_val) { case 0: func0(); break; case 1: func1(); break; } or with delegates and dictionary like this delegate void some_delegate(); Dictionary<int, some_delegate> some_dictionary = new Dictionary<int, some_delegate>(); some_dictionary[0] = func0; some_dictionary[1] = func1; some_dictionary[some_value].Invoke(); Are this two methods equal and which is preferred? Thanks.

    Read the article

  • MKReverseGeocoder delegate location?

    - by fuzzygoat
    I have a quick question regarding memory management that I am not quite sure about. I currently have a locationManager delegate that calls locationManager:didUpdateToLocation:fromLocation when it resolves the device location. My question is I am looking at adding ReverseGeoCoding after I have obtained the [newLocation coordinate] but am unsure about doing the alloc here, as each time locationManager:didUpdateToLocation:fromLocation gets called I will be alloc-ing a new MKReverseGeoCoder? // LOCATION -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { // GeoCoding: MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:[newLocation coordinate]]; [geoCoder setDelegate:self]; [geoCoder start]; [self foundLocation]; } Can anyone point me in the right direction with regards to this? I did try doing the alloc in application:didFinishLaunchingWithOptions: but then realised I did not have access to [newLocation coordinate]. many thanks gary

    Read the article

  • Performance of delegate and method group

    - by BlueFox
    Hi I was investigating the performance hit of creating Cachedependency objects, so I wrote a very simple test program as follows: using System; using System.Collections.Generic; using System.Diagnostics; using System.Web.Caching; namespace Test { internal class Program { private static readonly string[] keys = new[] {"Abc"}; private static readonly int MaxIteration = 10000000; private static void Main(string[] args) { Debug.Print("first set"); test7(); test6(); test5(); test4(); test3(); test2(); Debug.Print("second set"); test2(); test3(); test4(); test5(); test6(); test7(); } private static void test2() { DateTime start = DateTime.Now; var list = new List<CacheDependency>(); for (int i = 0; i < MaxIteration; i++) { list.Add(new CacheDependency(null, keys)); } Debug.Print("test2 Time: " + (DateTime.Now - start)); } private static void test3() { DateTime start = DateTime.Now; var list = new List<Func<CacheDependency>>(); for (int i = 0; i < MaxIteration; i++) { list.Add(() => new CacheDependency(null, keys)); } Debug.Print("test3 Time: " + (DateTime.Now - start)); } private static void test4() { var p = new Program(); DateTime start = DateTime.Now; var list = new List<Func<CacheDependency>>(); for (int i = 0; i < MaxIteration; i++) { list.Add(p.GetDep); } Debug.Print("test4 Time: " + (DateTime.Now - start)); } private static void test5() { var p = new Program(); DateTime start = DateTime.Now; var list = new List<Func<CacheDependency>>(); for (int i = 0; i < MaxIteration; i++) { list.Add(() => { return p.GetDep(); }); } Debug.Print("test5 Time: " + (DateTime.Now - start)); } private static void test6() { DateTime start = DateTime.Now; var list = new List<Func<CacheDependency>>(); for (int i = 0; i < MaxIteration; i++) { list.Add(GetDepSatic); } Debug.Print("test6 Time: " + (DateTime.Now - start)); } private static void test7() { DateTime start = DateTime.Now; var list = new List<Func<CacheDependency>>(); for (int i = 0; i < MaxIteration; i++) { list.Add(() => { return GetDepSatic(); }); } Debug.Print("test7 Time: " + (DateTime.Now - start)); } private CacheDependency GetDep() { return new CacheDependency(null, keys); } private static CacheDependency GetDepSatic() { return new CacheDependency(null, keys); } } } But I can't understand why these result looks like this: first set test7 Time: 00:00:00.4840277 test6 Time: 00:00:02.2041261 test5 Time: 00:00:00.1910109 test4 Time: 00:00:03.1401796 test3 Time: 00:00:00.1820105 test2 Time: 00:00:08.5394884 second set test2 Time: 00:00:07.7324423 test3 Time: 00:00:00.1830105 test4 Time: 00:00:02.3561347 test5 Time: 00:00:00.1750100 test6 Time: 00:00:03.2941884 test7 Time: 00:00:00.1850106 In particular: 1. Why is test4 and test6 much slower than their delegate version? I also noticed that Resharper specifically has a comment on the delegate version suggesting change test5 and test7 to "Covert to method group". Which is the same as test4 and test6 but they're actually slower? 2. I don't seem a consistent performance difference when calling test4 and test6, shouldn't static calls to be always faster?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >