If I use the navigation framework in silverlight and say mainFrame.Navigate(URI), does this always call the ctor of the page and create a new object? I create the objects of all my pages in the mainPage as they are used at a lot of places, but since this creates a new object the initializations are lost. Can I not use existing objects with this ?
Thanks
You have to work with the ContentLoader of the Navigation Frame....
Basically do your own implementation of INavigationContentLoader ....
David Poll has a ton of articles on his blog about INavigationContentLoader...
http://www.davidpoll.com/2009/11/30/opening-up-silverlight-4-navigation-introduction-to-inavigationcontentloader/
As well as this nice video + post of karl shifflett on Silverlight TV gives you great understanding...
http://channel9.msdn.com/shows/SilverlightTV/Advanced-Silverlight-Navigation-Scenarios-Part-2-Silverlight-TV-39/
http://karlshifflett.wordpress.com/2010/07/07/non-linear-navigation-in-silverlight-4/
let me know if this helps
Related
I am learning Objective-C Cocoa programming for OS X, and object-based programming in general, so I am a big novice here, so my question is a bit general and my guess is the answer to this is simply "experience"; however, I am curious if there is some route of knowledge to understanding what methods in various classes are best or perhaps required for getting tasks done.
For example, in a programming guide I am instructed to create a document-based program, and the document class contains an array to store data, with the following method bound to a button to create a new entry in the array:
- (IBAction)insertItem:(id)sender {
if (!theItems) {
theItems = [NSMutableArray array];
}
[theItems addObject:#"Double-click to edit."];
[theTableView reloadData];
[self updateChangeCount:NSChangeDone];
}
The array is "theItems" and its data is being presented in a TableView object. I understand that the steps here add a new string to the array and then refresh the table to display it, followed by setting the document to be set to an unsaved state.
What I am not getting is how one would know these specific steps and methods are required. Intuitively it seems one would just add items to the array, and that would be all that's required to have the new values simply show up in the table view for which the array is the data source, so how would one know that the tableView would need to be refreshed with the "reloadData" call? I can see someone (myself) figuring it out by trial and error, but is there some quick resource or guide (ie, some quick flow-chart) either in XCode or elsewhere that indicates for a table view that this would have to be a required action to display the new entry?
If I look at Apple's NSTableView class reference, it claims in the overview that you "modify the values in the data source and allow the changes to be reflected in the table view" which suggest the view is updated automatically, so the requirement to call "reloadData" on the view seems a little obscure.
Look for the guides. In the online class reference for NSTableView, there's a section at the top called "Companion Guides". For NSTableView, it lists the Table View Programming Guide for Mac. (In the prerelease 10.10 docs, the guides are listed under Related Documentation in the left-hand sidebar.)
I could have sworn this same information was available in Xcode's Documentation window, albeit somewhat hidden behind a "More related items" pseudo-link, but when I check right now there's no link to the guide anywhere in the NSTableView class reference. Which is a terrible oversight.
You can also browse or search the Guides section of the developer library.
Familiarity, studying the documentation and possibly reading some good books is the answer. For example, in the docs you quoted (emphasis mine)
you should modify the values in the data source and allow the changes to be reflected in the table view
You should do both these things. If you want it to happen "automatically", look into bindings, which uses several other Cocoa features you won't understand at this point either to do the table data source stuff for you. I'd recommend understanding what is happening manually before handing over control to bindings, so you have some chance of understanding when things go wrong.
As well as looking at the table view documentation, you also need to study the cell, delegate and datasource references. All of those objects work together to give you the functioning table view.
Is it possible to add documentation (not just comments) to your javascript methods in Sencha Architect. I cannot seem to add lines above methods because of the specific method views in Architect.
I am talking about the following documentation:
/**
* this documentation
*/
bla: function() {
//I do know how to add this comment!
}
UPDATE:
Seems that it is not possible :(
http://www.sencha.com/forum/showthread.php?281079-Sencha-Architect-Code-Documentation-%28JSDocs%
I will keep this thread open to see if someone knows a workaround to the problem.
Architect 3.1 or 3.1.1 will add commenting. It's done in prototype form but we are racing to add Ext JS 5 so it's on the back burner until then.
I had my iPhone app working, developed with Storyboard. I decided to take all of the methods that belonged in a SQLite method and move them to a new SQLite class (.h and .m).
Now I have errors that I can't seem to get rid of. The basic problem is the textfields on the "scene" are now unreachable from the SQLite class (they are in another class, where they belong). The properties are defined in EDVController.m... I am trying to reach them from SQLite.m.
I have read the docs, but can't find anything that fits my problem.
How do I do this?
I give full credit to Jeremy Roman... I would up using NSMutableDictionary to pass the parameters, and it works like a champ! Thank you Jeremy and Jia Yow.
I'm writing a simple Sencha Touch 2 Application with the new MVC Pattern of the Framework - so, there are models, stores, controllers and views and all is tied together with an Application.
Now, there is the possability to use "this.getApplication()" to get the instance of this super uber-class "Application".
And now there is the problem - getApplication() returns only the app-instance, if i'm in a controller - in a view, a model or a store, it is returning "undefined".
Basically, i can understand the idea behind this behavior - your business has to be in controllers, nowhere else.. and so you don't have to know the app-instance in stuff like stores, views or models...
Okey but.. it would be extremely nice to have global-properties living in the main-app.
For example, i want to define my webservice-url globally in the Application and use that variable everywhere i need to - and unfortunately, i need this url in a store too.
Now, the only way i see to access this global variable in a store is the way through my Namespace. Instead of using "this.getApplication().serviceUrl" i found only the solution through the namespace with "NameOfMyApp.app.serviceUrl" - and that could not be the best way to solve this.
Any ideas about that problematic? Is there a better, always working way to get the app instance from everywhere? Or, where should i store global variables if not in the Application?
You can access the application instance on the AppName.app property in the latest Sencha Touch 2 betas.
Ext.application({
name: 'Sencha',
launch: function() {
// Logs the application instance
console.log(Sencha.app);
}
});
looks like Ext.app.Application.appInstance is app name agnostic solution
I work with ExtJS 4.1.1a and Ext.app.Application.instance seems to be the only solution. From a controller you can use this.application.
In .NET I just do something like DataForm.Source = Object and then magic happens. Platform routes data changes from ui fileds to object properties, does validation and so on. Can I do something similar with Cocoa Touch and CoreData objects?
The closest thing in Cocoa is 'Key-Value Observing'. In the desktop Cocoa framework you can use bindings to hook user interface elements up to underlying objects so that changes in the objects or UI elements are reflected in the other.
Whilst Cocoa on iOS doesn't have this sort of UI bindings, you can still use 'Key-Value Observing' to synchronise changes in the data model with UI elements as described here:
http://developer.apple.com/library/iOS/#documentation/General/Conceptual/Devpedia-CocoaApp/KVO.html
I wrote a little open-source library that provides some simple data-binding functionality. It's basically just a wrapper around key-value observing (KVO).
http://github.com/kristopherjohnson/KJSimpleBinding
There are a few other similar libraries on GitHub:
http://github.com/dewind/KeyPathBindings
http://github.com/jonsterling/Observe
http://github.com/mruegenberg/objc-simple-bindings
http://github.com/zeasy/EasyBinding
Probably should also mention Github's Reactive Cocoa, a framework for composing and transforming sequences of values, an objective-C version of .NET's Reactive Extensions (Rx).
Binding mechanics can be done really simple (from the sample):
// RACObserve(self, username) creates a new RACSignal that sends a new value
// whenever the username changes. -subscribeNext: will execute the block
// whenever the signal sends a value.
[RACObserve(self, username) subscribeNext:^(NSString *newName) {
NSLog(#"%#", newName);
}];
Don't forget NSFetchedResultsController.
Not a full blown data bound controller, but makes table views a lot easier to use with Core Data.
If you're using Swift, check out Bond framework: https://github.com/ReactiveKit/Bond
Binding is as simple as:
textField.reactive.text.bind(to: label.reactive.text)
It plays well with functional:
textField.reactive.text
.map { "Hi " + $0 }
.bind(to: label.reactive.text)
And provides simple observations:
textField.reactive.text
.observeNext { text in
print(text)
}
STV (http://sensiblecocoa.com) is a framework that can do that within tableviews
I use CoreDataTableViewController from the Stanford University for my TableViewControllers. It hides a lot of details that you would normally implement in your TableViewController.
Googling for CoreDataTableViewController.h and .m will help you on the road. There are versions from several courses available, the latest does ARC, the old ones don't.
For syncing labels and edit fields with an NSManagedObject, I am still looking for a good solution.
Yes, there is a data binding framework that integrates well into Interface Builder and requires only minimal code overhead (if at all).
Take a look at https://github.com/mutech/aka-ios-beacon
EDIT:
You can for example bind a table view to a fetched results controller simply by setting the data source binding property of the table view in interface builder to:
[ yourResultsController ] { defaultCellMapping: "YourCellId" }
And the only thing you have to do is to define a property yourResultsController in your view controller.
The wiki provides a rather complete documentation and a lot of example use cases.