MicroStrategy ONE
Retrieve Images and Quick Symbols in iOS
Images
In a grid, attributes might be defined to have attribute forms that are images. The MicroStrategyMobile framework performs the download of such images in the background and notifies the ImageCacheCallback object assigned to the image download once the download is complete.
MicroStrategy caches images to improve performance. The ImageCache object includes all the logic for image caching, providing a convenience method to retrieve images for a widget:
-(void)getImage:(NSString *)imageUrl callback:(id<ImageCacheCallback>) cback project:(ProjectInfo*)projectInfo;
This method is asynchronous and notifies the callback once the download is complete.
-
Starting the image download
A sample usage of the getImage method in the widget’s code implementation is shown in the following snippet. The reference to self is to the widget instance.
CopyMSIHeaderValue *value = ... //retrieve Header Value while iterating on the grid's data
NSString *displayValue = value.headerValue;
MSIMSIReportDisplayInfo* document = self.document;
[[ImageCache getImageCache]getImage:imageName callback:self project:document.project];
-
Retrieving the image
Widgets that want to fetch images provided by a grid in MicroStrategy must conform to the ImageCacheCallback protocol which defines two methods:
Copy-(void)imageReceived:(UIImage *)image forURL:(NSString*)url withLocalURL:(NSString*)localUrl isHitCache:(BOOL)hitCache;
This method is called when the image has been downloaded and a pointer to its named image is passed. Custom widgets can use this pointer to use the images in the custom widget.
Copy-(NSString *)getSubscriptionId
This method provides an identifier for the download service. You would typically return the class name that called the service.
Quick Symbols
The following code snippet illustrates how to retrieve a quick symbol, such as or . The symbol is retrieved by the GraphicUtils class, which contains a convenience method to retrieve quick symbols.
MSIHeaderValue *value = ...//retrieve Header Value while iterating on the grid's data
if (value.semantics == SemanticTypeQuickSymbol ) {
label.text = [GraphicUtils getQuickSymbolUnicode:value.headerValue];
}
The relationship between the header value and the type for a Quick Symbol is established in the QuickSymbol enumeration defined in Enums.h, as shown in the code snippet below:
typedef enum _QuickSymbol {
SymbolReserved = 0, SymbolBlackCircle = 1, SymbolBlackSquare = 2, SymbolLozenge = 3, SymbolBlackDiamond = 4, SymbolInkBlot = 5,
SymbolWheelofDharma = 6, SymbolBlackFlorette = 7, SymbolPlaceInterestSign = 8,SymbolHeavyCheckMark = 9, SymbolHeavyBallotX = 10,
SymbolRightArrow = 29, SymbolUpArrow = 30, SymbolDownArrow = 31
} QuickSymbol;
Based on these definitions, a MSIHeaderValue object with semantics type SemanticTypeQuickSymbol and headerValue of 1 would correspond to a black circle quick symbol.