NSUserdefaults doesn't call functions - call

I'm using NSUserdefaults to save/load values (slider, switch, label) but it does work only on the ViewController layer and doesn't have effect on the functions that graphic elements call.

Related

Add empty overlay to leaflet map?

Looking for a way to add an empty overlay to a Leaflet map. I have multiple Leaflet overlays that load in their data from a realtime server. Because I am using a custom UI control and not the default Leaflet one, I have a listener that every time new markers are created, checks to see whether their associated layer is active, and if it is, adds the markers to that layer.
$rootScope.on('newMarkers',markers)->
type = *fn to find type*
if mapFactory.currentLayers[type]?.active
mapFactory.addLayer(markers, type)
)
I don't think building in logic to see whether it's the first time a marker is being added to that layer makes sense, and would rather create an empty layer and add data to it after. I know you can do this with the L.geoJson type, but this layer is made entirely of plain markers. Any suggestions
You could use L.LayerGroupfor this:
Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.
Reference: http://leafletjs.com/reference.html#layergroup
Or L.FeatureGroup:
Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.
Reference: http://leafletjs.com/reference.html#featuregroup

Winapi Multiple Windows same WindowProc

I am developing a GUI with WINAPI and I've a question.
I made a custom progress bar with the respective Procedure for handling it's messages.
I paint the progress bar myself. For the progress bar percentage I use a static variable that I update using a custom message and then I repaint the progress bar by using InvalidateRect.
Now how could I optimize my code so I could create multiple windows of my ProgressBar class.
The problem is that I can't use that same static percentage variable for all of them! So each instance should have it's own percentage variable.
Thank you
All windows have at least one pointer-sized user data variable that you can use for whatever purpose you like - it is accessed via GetWindowLongPtr/SetWindowLongPtr with the index GWLP_USERDATA.
Additionally, when you register a window class, you can specify additional user data to be allocated for each window in your class, using the WNDCLASS member cbWndExtra. For example, if you set this to sizeof(DWORD_PTR) when you registered your class, you could also store a DWORD_PTR-sized value using SetWindowLongPtr with index 0.
Depending on how much data you want to store per-window, you can store it directly using the above methods, or allocate your own structure and store a pointer to it (remembering to free the data when the window is destroyed).
An additional method of storing data per-window is using window properties via the SetProp and GetProp functions, which let you store one or more pointer-sized name/value pairs.
Dont make the percentage variable static. Make it part of the class and read/write from getter/setters

layoutAttributesForItemAtIndexPath - when is it called?

I am currently playing around with some demo projects for the new UICollectionView.
Most of this demos override layoutAttributesForItemAtIndexPath in there subclasses. But the method is never called in one of that example.
From the Apple docs i know that i have to override layoutAttributesForItemAtIndexPath
I cannot not figure out in which situation this method is called.
Is this method just for special cases?
Maybe you can find out in Apple doc, Subclasses must override both layoutAttributesForElementsInRect and layoutAttributesForItemAtIndexPath
read this:
layoutAttributesForElementsInRect:
Returns the layout attributes for all of the cells and views in the specified rectangle.
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
Parameters
rect
The rectangle (specified in the collection view’s coordinate system) containing the target views.
Return Value
An array of UICollectionViewLayoutAttributes objects representing the layout information for the cells and views. The default implementation returns nil.
Discussion
Subclasses must override this method and use it to return layout information for all items whose view intersects the specified rectangle. Your implementation should return attributes for all visual elements, including cells, supplementary views, and decoration views.
When creating the layout attributes, always create an attributes object that represents the correct element type (cell, supplementary, or decoration). The collection view differentiates between attributes for each type and uses that information to make decisions about which views to create and how to manage them.
Availability
Available in iOS 6.0 and later.
Declared In
UICollectionViewLayout.h

When to use ArrayCollection or Array in as3?

I know that an ArrayCollection is a wrapper over an Array, but what I wanted to know is when to choose one over the other? Will the over usage of ArrayCollections result in performance?
The main advantage of ArrayCollection is collectionChange event which allows to get advantage of data binding with it.
Some others are:
Possibility to filter or sort elements of collection without modifying or copying of underlying array.
Implementation of ICollectionView which allows to create a cursor and iterate collection with it.
Display of multiple arrays in a datagrid / etc (in this case, arrays are automatically converted to arrayCollections anyway)
If you don't need any of these advantages use simple Array.

How use a DocumentPaginator asynchronously via GetPageAsync with XpsDocumentWriter?

The idea here is that I have a DocumentPaginator that I want to use with an XpsDocumentWriter or PrintDialog as both have the option of printing given a paginator. When I use either, i.e. XpsDocumentWriter.Write[Async] or PrintDialog.PrintDocument, the paginator is accesed via GetPage vs. GetPageAsync which I've overridden in derived DocumentPaginator class.
Outside of manually consuming the paginator and feeding Visuals to the document writer, is there a way to trigger the use of the Asyc functions of a DocumentPaginator?

Resources