the warning "'uniqueIdentifier' is deprecated" in project based on cocos2d-box2d - cocos2d-iphone

I create a new project based on cocos2d-box2d, and there are always 4 warning in two files, one is CLScoreServerPost.m, the code has warning is following
[self addValue:[[UIDevice currentDevice] uniqueIdentifier] key:#"cc_device_id"];
and another is CLScoreServerRequest.m, the code has warning is following
device = [[UIDevice currentDevice] uniqueIdentifier];
both of them show the same warning: 'uniqueIdentifier' is deprecated
so what should I do? many thanks

+(NSString *)GetUUID
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return [(NSString *)string autorelease];
}

You can use for example OpenUDID https://github.com/ylechelle/OpenUDID
As LearnCocos2D told in a comment there is also a topic on SOF : UIDevice uniqueIdentifier Deprecated - What To Do Now?

Related

Unique identifier associated to the iCloud account

I would like to use a code to identify users, without asking them for their email address or other sensitive information, that would also possibly follow her when she changes device. Long ago I trustily implemented the following piece of code:
NSString *strApplicationUUID=nil;
+(NSString*) sharedUdid{
if (!strApplicationUUID){
NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
strApplicationUUID = [SSKeychain passwordForService:appName account:#"incoding"];
if (strApplicationUUID == nil) {
strApplicationUUID=[[NSUserDefaults standardUserDefaults] objectForKey:#"udid"];
if (!strApplicationUUID) strApplicationUUID=[[[UIDevice currentDevice] identifierForVendor] UUIDString];
else strApplicationUUID = [[NSUUID UUID] UUIDString];
[SSKeychain setPassword:strApplicationUUID forService:appName account:#"incoding"];
}
}
return strApplicationUUID;
}
That I unfortunately found producing all but unique identifiers for each user. So I temporarily switched to using the token, notwithstanding its length and the fact it is linked to a single device. Is there some better solution?
I switched to using the CloudKit identifier.

No error description provided though QSqlQuery::exec fails

I get into the if block:
if ( !_query.exec( ) )
{
QString errdb = _db.driver()->lastError().databaseText();
QString errdrv = _db.driver()->lastError().driverText();
//...
but errdb and errdrv are empty.
Is there another way to check what went wrong?
You can get the error using QSqlQuery::lastError(), in your case _query.lastError().
Quote from the Qt documentation:
Returns error information about the last error (if any) that occurred
with this query.
What you need is _db.lastError().text().

How to get a table cell in aspose slides?

I see this sample:
http://www.aspose.com/docs/display/slidesnet/Creating+a+Table+from+Scratch
...and when I try to use it, I see that the library has changed (I guess) and it needs me to do sth like that:
int lIndex = pSld.Shapes.AddTable(pUppLeftPoint.X, pUppLeftPoint.Y, pColumnWidths, pRowWidths);
TableEx lTable = (TableEx)pSld.Shapes[lIndex];
(I can only cast to TableEx and not to Table)
But I cannot find how to get the cell's TextFrame. The site says :
TextFrame tf = table.GetCell(0, 0).TextFrame;
But I have nothing like this...
Am I missing sth?
Any ideas?
EDIT :
I found out that my code is for PPTX and the site's code for PPT:
http://www.aspose.com/community/forums/thread/453613/facing-performance-issue-due-to-addtable-method-of-pptx.aspx
But, again, how do you get the cell's contents in PPTX?
Ha! I got it!
There's an indexer:
lTable[i,j]

How do I use the version number of a C++ program in the program itself? [duplicate]

I would like to add the current version into the "about" section of my app.
As seen in this attached screenshot Apple offers versioning.
How do you display these settings in your app?
After further searching and testing, I found the solution myself.
NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSLog(#"%i Keys: %#", [infoDictionary count],
[[infoDictionary allKeys] componentsJoinedByString: #" ,"]);
This snipplet gave me the following output:
20 Keys : NSBundleResolvedPath ,CFBundleVersion ,NSBundleInitialPath ,CFBundleIdentifier ,NSMainNibFile ,CFBundleIconFile ,CFBundleInfoPlistURL ,CFBundleExecutable ,DTSDKName ,UIStatusBarStyle ,CFBundleDevelopmentRegion ,DTPlatformName ,CFBundleInfoDictionaryVersion ,CFBundleSupportedPlatforms ,CFBundleExecutablePath ,CFBundleDisplayName ,LSRequiresIPhoneOS ,CFBundlePackageType ,CFBundleSignature ,CFBundleName
So the solution is as simple as:
NSString *version =[[[NSBundle mainBundle] infoDictionary] valueForKey:#"CFBundleVersion"];
However, this is not the Current Project Version as seen in the screenshot but the Bundle Version of the plist file.
Look into your Info.plist file which should have keys like CFBundleVersion and CFBundleShortVersionString
Those items in the Build Info are not available to your built app. They are placeholders that you could possibly pull into your app. What is in your app is anything that you place in, say, the Resources folder of your app, like any text files, or plists, or a nice picture of your versioning engineer.
Now, you could pull some of the items in the Build Info window into a info.plist, using special identifiers, such as ${VERSION_INFO_PREFIX} or other token. The tokens are available if you click on any of the items on the left hand side in the window you have included above. For example, click on the word "Current Project Version" and copy the token that you see at the bottom, "CURRENT_PROJECT_VERSION". Then go to your plist file, and add an entry. Give it any name you want or "Current Project Version". Paste in ${CURRENT_PROJECT_VERSION} on the right hand side. Now that value is available to you from your app, programmatically. Of course, someone now has to enter that value into the appropriate place either in the Build Info window or elsewhere. It might just be easier just to manage this and fields like this in the info.plist file. It's up to you how you'd like to handle these things.
Here is how I get version info out of my info.plist:
+ (NSString *) getAppVersionNumber;
{
NSString *myVersion,
*buildNum,
*versText;
myVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleShortVersionString"];
buildNum = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleVersionKey];
if (myVersion) {
if (buildNum)
versText = [NSString stringWithFormat:#"Version: %# (%#)", myVersion, buildNum];
else
versText = [NSString stringWithFormat:#"Version: %#", myVersion];
}
else if (buildNum)
versText = [NSString stringWithFormat:#"Version: %#", buildNum];
NSLog(versText);
return versText;
}
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] valueForKey:#"CFBundleVersion"];
returns me always the same value(initial version) even if i change the version from the project settings but.
NSString * appVersionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:#"CFBundleShortVersionString"];
does the trick.
For the lazy here is the swift version :
NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString")!
NSBundle.mainBundle.infoDictionary[#"CFBundleShortVersionString"];

iOS unit testing with Core Data

I'm writing some tests to exercise a CoreData object: coreobj
in my test case setup method I have the following initialization:
- (void)setUp
{
[super setUp];
NSManagedObjectModel *mom = [NSManagedObjectModel mergedModelFromBundles:[NSBundle allBundles]];
NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
STAssertTrue([psc addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:NULL] ? YES : NO, #"Should be able to add in-memory store");
m_managedObjectContext = [[NSManagedObjectContext alloc] init];
m_managedObjectContext.persistentStoreCoordinator = psc;
}
My first test runs fun, but my second test generates this error in the log file:
Can't merge models with two different entities named 'coreobj'
Suggestions?
You can have a look at Blog post with grate explanation
It does not solve all the problems do ...
Setup will execute between each test case. It maybe your getting multiple contexts entities that are causing test pollution between each test.