I have leaderboards with IDs "1", "2" and "3". "1" and "2" was submitted for current version of app which is on the appstore, "3" is a new one. Test device has values submitted for all categories. To open Leaderboards from within app I use the following code:
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != NULL)
{
leaderboardController.category = GameMode != MAIN ? #"3" : #"1";
leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboardController.leaderboardDelegate = self;
[mainWindowController presentModalViewController:leaderboardController animated:YES];
}
If works well on ios 5.0.1, 5.1.1 both for "3" and "1", but I have a strange issue on ios 6.0.1: when I try to open category "1" - no problem, but when I open "3" - Game Center usually shows just "leaderboard" screen with default category ("1") values.
Maybe this happens because my "3" category isn't "online" yet and when I release the new version of the app where "3" category will be included this problem will disappear? I tried to
change "3" to "2":
leaderboardController.category = GameMode != MAIN ? #"2" : #"1";
and it worked for some time, and then again I see "leaderboard" screen with default category values.
Does anybody happen to have such a problem?
Update:
as a temporary solution I set category to nil to see all the categories.
Related
I have created a view for a "details" page, and have set up a visual query to get the required item from a query string variable.
Testing the query works, and a single item is returned in the test:
{
"Default": [
{
"Title": "The Person",
"JobTitle": "CEO",
"Organization": "The Company",
etc (exactly what is expected)
}
]
}
This is piped to the Default input of the 2sxc Target, and running the test shows that 1 item is sent to the Target.
Now, when I actually execute the module, what I get is "No demo item exists for the selected template." which indicates that the data is not actually getting to the module.
I have selected the query as the data source for the view.
How to debug this?
You're running into a different problem: your view has a content-type defined, but no demo-item. In this scenario, it shows the message you see. So either say "no content-type" or give it a demo-item. Then the template is run.
I'm trying to make an app that will receive local notifications with random text. I used some code but it's not working well. It's coming only "006" or "005", and it won't change.
The code that I used is:
let myArray = ["000", "001", "002", "003", "004", "005", "006"]
let notification = UILocalNotification()
notification.alertBody = myArray[Int(arc4random_uniform(UInt32(myArray.count)))] // text that will be displayed in the notification
notification.fireDate = NSDate() // right now (when notification will be fired)
notification.soundName = UILocalNotificationDefaultSoundName // play default sound
notification.repeatInterval = NSCalendarUnit.NSHourCalendarUnit // this line defines the interval at which the notification will be repeated
UIApplication.sharedApplication().scheduleLocalNotification(notification)
Can you please show me where I made mistake ? Thanks.
What you are doing is correct. Maybe you haven't tried your code enough and had a long string of extreme values.
So in my MongoDB Collection I have this structure:
"_id" : "Object("-----------")
"name" : "John Doe"
"tool" : {
"hammer" : {
"name" : "hammer 1",
"characteristics" : [
{
"length" : "9 inches"
},
{
"weight" : "4 pounds"
}
]
I know the data may seem a little strange but I can't put the actual data online so I had to input some dummy data. So essentially what I would like to do is be able to update the array that is nested within those objects. So I would like to be able to update the weight or add a new characteristic that I haven't previously entered into it. So for example, add in "metal" : "steel" as a new entry into the array. Currently I'm using a Rest API built in Node.js and Express.js to edit the db. When I was trying to figure out how to dig down this deep I was able to do it with an array at the highest level, however I haven't been able to figure out how to access an array when its embedded like this. So what I was wondering if anybody knew if it was even possible to edit an array this far down? I can post code from controller.js and server.js file if needed but I figured I'd see if it's even possible to do before I start posting it. Any help would be greatly appreciated!
You can use findAndModify to $push it into the array. You have to specify the path precisely though:
db.tools.findAndModify( {
query: { name: "John Doe"},
update: { $push: { tool.hammer.characteristics: {metal: "steel"} }
} );
Step One
> db.myCollection.find();
{ "_id" : ObjectId("2358523892345"), "field1" : "value 1", "field2" : [ { "subfield1" : "value 2" }, { "Subfield2" : "value 3" } ], "field3" : "value 4" }
I am wanting to rename the field Subfield2 to subfield2. I tried:
Step Two
> db.myCollection.update ( { "field3": "value 4" }, {$rename: {"Subfield2": "subfield2" } } )
And then ran find() again and get the same results as in 'Step One' ie the field is not renamed.
Using MongoDB terminology, I think what I am trying to do is 'rename a field in an embedded document in an array'.
References
http://docs.mongodb.org/manual/reference/operator/rename/
It seems to not be possible to rename a field within an array from the command line as answered in this question:
MongoDB rename database field within array
As mentioned in the documentation there is no way to rename fields
within arrays. Your only option is to iterate over your collection
documents, read them and update each with $unset old/$set new
operations.
It is possible to change these values via RockMongo however as suggested by user Liad Livnat.
For my particular instance, whist there I also removed the array and changed the structure to:
{
"field1": "value 1",
"field2": {"subfield1": "value 2", "subfield2": "value 3"},
"field3": "value 4"
}
Querying this object was then possible with:
db.myCollection.find( {"field2.subfield2":"value 3"} );
if you want to update it manually i suggest you will install rockmongo, rockmongo is a great tool working with mongo databases, just extract it on your server and connect to your database.
there you will find very easy update to mongo database, tables and records.
rock mongo
My backbone.js has three views:
List of categories
List of items in category
Form for individual item
I'm using backbone.js router to navigate between these views. The user flows in the app go 1<-->2, 2<-->3 and 3 --> 1. The user can navigate back and forth using browser back and forward buttons, which is wanted behavior. Deep linking to any item works also.
The problem is that I want to keep the history clean. Here's an example usage flow:
User opens list of categories. History: "Category list" (correct)
User select "My category". History: "My category" < "Category list" (correct)
User select "My item". History: "My item" < "My category" < "Category list" (correct)
User fills form and saves, is redirected to "Category list". History: "Category list" < "My item" < "My category" < "Category list" ( should be just "Category list" )
Another example:
User opens url of "My category"
User presses home button. History: "Category list" < "My category", should be "Category list"
Any ideas on how to implement this in a clean way?
There is no way to implement the first example that you provided. You cannot implement the first example because there is no way to "delete" the browser history using Javascript.
There is no way to clear the session history or to disable the back/forward navigation from unprivileged code. The closest available solution is the location.replace() method, which replaces the current item of the session history with the provided URL.
- https://developer.mozilla.org/en/DOM/window.history
At best you can prevent the current page from being added to the browser history by using window.location.replace or window.history.replaceState. Backbone.js provides a convenient way of doing this by calling router.navigate(fragment, [options]) on your router object and specifying {replace: true} in the options.
Instead of relying on different routes to determine which view to display, I would try instead writing a master view which could handle showing/hiding the specific views.
EDIT
Ok, entering hacky territory...
Since it seems that the "Category List" page is the page where history should be "reset", the solution I have posted attempts to solve both use cases you have mentioned. The code keeps track of a historyState variable, which represents when the "category-list" page is visitied as well as the other pages visited after it.
// in your application init...
$(function(){
window.historyState = -1;
router = new Backbone.Router({
routes: {
"category-list": category-list,
"category": category,
"item": item
}
category-list: function(){
historyState = 0;
},
category: function(){
if(historyState >= 0)
historyState++;
},
item: function(){
if(historyState >= 0)
historyState++;
}
});
});
If historyState is -1 - we have not yet visited the "category-list" page.
If historyState is 0 - we are currently on the "category-list" page.
If historyState is greater 0 - number of pages visited since viewed "category-list" page.
Now anytime a link is used to navigate to the "category-list" page, make sure it calls the following method to handle the appropriate navigation.
function routeToCategoryList(){
if( historyState > 0 ){
// 'category-list' already exists in our history route to that page.
window.history.go((historyState * -1));
} else {
// otherwise, don't store an entry for the current page we are on.
router.navigate("/category-list", {trigger: true, replace: true});
}
}
If the 'category-list' page has already been visited go back in history the appropriate number of entries (this unfortunately keeps the other pages in the history, so you can still go forward to them). Otherwise if the 'category-list' page hasn't been visited yet navigate to it and be sure not to add the current page to the history.
There is no way to delete history from backbone history, you can re-route the navigation by adding some logic by getting current fragment
or you can use history.js (Works on most of the browser)
while https://developer.mozilla.org/en/DOM/window.history is only for Mozila firefox so this does not work for android app