NSDictionary >> ObjC to Oxygene

Hi,
the “NSDictionary” in ElementsWiki is currently empty.
I’ve translated this ObjC Code to Oxygene, except the last line.
What’s the currect Nougat Syntax to initialize the NSDictionary with values?

UIFont *font = [UIFont fontWithName:@"Courier" size:kCellFontSize];
// Make a copy of the default paragraph style
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
// Set line break mode
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
// Set text alignment
paragraphStyle.alignment = NSTextAlignmentRight;

NSDictionary *attributes = @{ NSFontAttributeName: font,
                    NSParagraphStyleAttributeName: paragraphStyle };

I wish you a happy new year and many successes in 2014.

Did you try Oxidizer? (Paste Objective-C as Oxygene)? It’s on context menu

Hi deksden,
what oxygene/hydrogene version do you use?

I using the lastest oxygene beta (7.0.62.1431) and my oxydizer still doesn’t support Objective-C.

I’ve found a solution using Generics (NSMutableDictionary<NSString,NSObject>).

            var paragraphStyle:NSMutableParagraphStyle  := NSParagraphStyle.defaultParagraphStyle.mutableCopy;
            paragraphStyle.lineBreakMode := NSLineBreakMode.NSLineBreakByTruncatingTail;
            paragraphStyle.alignment := NSTextAlignment.NSTextAlignmentCenter;

            var attribs:= new NSMutableDictionary<NSString,NSObject>;  
            attribs.setObject(columnFont) forKey(UIKit.NSFontAttributeName);
            attribs.setObject(columnColor) forKey(UIKit.NSForegroundColorAttributeName);
            attribs.setObject(paragraphStyle) forKey('NSParagraphStyle');

            columnString.drawInRect(textFrame) withAttributes(attribs);

This works for me, but I wondering, what’s the Oxygene syntax for following ObjC code:

NSDictionary *attributes = @{ NSFontAttributeName: font,
                    NSParagraphStyleAttributeName: paragraphStyle };

i’m afraid we don’t have a syntax for dictionary literals, right now (neither on Cocoa nor on .NET), in Oxygene. it’s on the list, but until then you;ll need to use one of the initializer methods such as dictionaryWithValues:forKeys: or whatever it’s called, manually. or of course create a NSMutableDictionary, and call setObject:forKey, as you did.

we DO have an issue logged to add a syntax for this in the future.

Isn’t a big problem.
We can manage that using InitWith... and setObject() forKey().

Marc,
why has “deksden” an ObjC Oxydizer and whether it is right that this Oxydizer is missing in my Oxygene Beta 7.0.62.1431…? Do I have to install the latest RTM to get the ObjC Oxydizer?

Oxidizer/ObjC should be freshly enabled in the very latest alpha build from ~1week ago.

I use Alpha 7.0.62.1431 (from Dec.20) on two PCs.
There is no Oxydizer for Objective-C in both installations.
Neither in solution explorer (Add->Import Objective-C) nor in the context menu (Oxydizer -> Paste ObjC as Oxygene).

Missing Prerequisites?

Same here, I am using the Alpha 7.0.62.1431 and there is no Oxidizer for Objective-C available.

Sorry, I m also did not have oxidizer for obj-C, just .net one. But it will be cool to have some for cocoa also!

Hmm I’ll check with the team. This was supposed to get enabled for the last alpha. I’ll make sure it goes into the next one.