[Solved] How do I create delegates in Objective-C?

An Objective-C delegate is an object that has been assigned to the delegate property another object. To create one, you define a class that implements the delegate methods you’re interested in, and mark that class as implementing the delegate protocol. For example, suppose you have a UIWebView. If you’d like to implement its delegate’s webViewDidStartLoad: … Read more

[Solved] Delegates vs Calling of Functions [closed]

Well, “the essential idea” of “delegation” is simply: “identify Someone Else that you can ask.” In this example, the Compare class exists to “compare two objects.” But you’ve said that it is to delegate that responsibility to some other function that is not a part of its own definition. Furthermore, you specify exactly what an … Read more

[Solved] C# method signatures – restricting types – what’s the correct terminology? [closed]

I think the term you are looking for is generic type constraints. From the linked MSDN article: When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code tries to instantiate your class by using … Read more

[Solved] Prevent duplicates from array, based on condition [closed]

You can write your own extension method that works like the built-in LINQ methods: public static class Extensions { public static IEnumerable<T> DistinctWhere<T>(this IEnumerable<T> input, Func<T,bool> predicate) { HashSet<T> hashset = new HashSet<T>(); foreach(T item in input) { if(!predicate(item)) { yield return item; continue; } if(!hashset.Contains(item)) { hashset.Add(item); yield return item; } } } } … Read more

[Solved] ios delegate and scrollView Invalid

I suspect that menuVC is dealocated, and only its view exist on screen, that may be the problem why delegates did not work. You can make the menuVC a strong property on your view controller, so it will not be dealocated when your method is finished. Or better set your menuVC as child controller self.addChildViewController(menuVC) … Read more

[Solved] Refactoring UITableView delegates for iOS7 and iOS8

self.tableView setDelegate: assigns a weak reference; if you don’t hold your own reference to this object, it will get collected. This is why you’re seeing the crash. The system has collected the memory that was assigned to your delegate, then reassigned the memory to an NSArray. Your table tries to call methods on the delegate … Read more

[Solved] why delegate work as ref? [closed]

You can change the method like that: public class Util { public static T[] Transform<T>(T[] values, Transformer<T> t) { return values.Select(x => t(x)).ToArray(); } } Then you can call it like var result = Utils.Transform(values, Square); If you can’t change that method, then you need to copy the array before calling: var result = values.ToArray(); … Read more

[Solved] How to create a method that allows arrays to act like single values?

Do not use this answer, just use Select() method much simpler. class Program { static void Main(string[] args) { string[] s = new string[] { “hi”, “hello”, “what’s up” }; string[] newS = s.ArrayTo<string>(x => x.Remove(0, 1) ); foreach (string str in newS) Console.WriteLine(str); } } static class Ext { public static T[] ArrayTo<T>(this T[] … Read more

[Solved] What is the VB.Net equavilent of the following

Very similar to the generated code, but there are some changes. I don’t know what the generator was doing with Key, and I don’t think it’s necessary to bracket the Error keyword in this context. Dim Result = JsonConvert.DeserializeObject(OF T)(parsed(“result”).ToString(), _ New JsonSerializerSettings With { .Error = AddressOf HandleDeserializationError} ) Protected Sub HandleDeserializationError(sender As Object, … Read more