w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Dispatch Queue and global NSMutableDictionary - Objective C
Try to call the other method(which is using your jsonarray) through nsnotification...I am not sure there might some other ideas/ways of doing this.But i am presenting what i have in my mind. Put this code inside your fetchedData method, NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(someMethod:) name:@"JSonDownloaded" object: jsonArray]; [[NSNotificationCenter defaultCenter] postNotificationName:@"JSonDownloaded" object: jsonArray]; -(void)someMethod:(NSNotification *)nspk { NSLog(@"%@",nspk.object); //Only after this you can able to access the jsonArray. } Don't forget to unregister the observer.

Categories : Objective C

Deleting inside an NSMutableDictionary inside an NSMutableArray
Use [NSMutableArray removeObject:]: Removes all occurrences in the array of a given object. NSMutableArray *array = ...; [array removeObject:@"<null>"]; Note: your array contains a mix of dictionary and strings objects; not just dictionary objects.

Categories : IOS

Acessing array inside form variable sent
If the form field name is TRANSACTION[0].ID_FOR_SENDER_TXN (which is what your debugging loop is indicating), then you should address it as: form['FORM.TRANSACTION[0].ID_FOR_SENDER_TXN'] To clarify: When you access a variable using this notation: <cfset pTxnId = FORM.TRANSACTION[0].ID_FOR_SENDER_TXN /> ColdFusion expects this data structure: It looks for a key in the form named transaction, and tries to get the 0th index from it (side note: this wouldn't work in CF anyway, arrays begin with index 1), and as that first item in the array, it's expecting a structure with a key named ID_FOR_SENDER_TXN. However, what PayPal is sending you is actually using this format: This explains the error message: "Element TRANSACTION is undefined in a Java object of type class [Ljava.la

Categories : Arrays

adding NSMutableDictionary to NSMutableDictionary adds dictionaries as string
Just try [result addEntriesFromDictionary:mainDictionary]; without the for loop. (Just in case mainDictionary is the desired dictionary that you want to add into the other dictionary

Categories : IOS

ios how to access to a node inside of json structure from nsmutabledictionary
So the best way to figure something like this out is to just use NSLog to print out what the format of the dictionary looks like. Anyway, you should be able to access top level objects through objectForKey, and then objects on inside levels through objectForKey or by iterating through them if it is an array not a dictionary.

Categories : IOS

Adding NSMutableDictionary with NSMutableDictionary to NSMutableArray?
Okay I think I see what you're trying to do here. So basically, you're trying to put an array of tools in each index of an array of strategies in each index of an array of questions. So something like: Question 1 Strategy 1 Tool 1 Tool 2 Strategy 2 Tool 1 Question 2 Strategy 1 Tool 1 Tool 2 Strategy 2 Tool 1 The code should be something like this: NSMutableDictionary *toolDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"tool1 info",@"tool1 key", @"tool2 info", @"tool2 key", nil]; NSMutableDictionary *stratDict = [[NSMutableDictionary alloc] initWithObjects:[NSArray arrayWithObjects:toolDict,toolDict,toolDict, nil] forKeys:[NSArray arrayWithObjects:@"strat1 key",@"strat2 key",@"strat3 key", nil]]; //loop through # of questions and add strat dict to each NSMutab

Categories : Objective C

Are there languages which compile to Objective-C or are binary compatible with Objective-C -> Coffeescript for Objective-C
While the primary way to use eero is to have it compile to native code, it does support source-to-source translation as well (from eero to standard Objective-C/C++). Please see https://github.com/eerolanguage/eero/wiki/Translator for more details. It really needs to be documented in a more obvious place...

Categories : IOS

How to call c++ method inside objective C
Your method should be like this -(BOOL) testMethodWithLargeString:(NSString *)largestring smallString(NSString *)smallstring { return YES; } For accessing this method : BOOL result = [<classObject> testMethodWithLargeString:string1 smallString:string2]; If the method is in self class, use self otherwise you need to use an object or class. Also, a convention of writing multiple parameterized method, (breaking it into multiple line) : BOOL result = [<classObject> testMethodWithLargeString:string1 smallString:string2]; And do I have to include some library so I can use string type? NO, You dont have to use any library like string.h In cocoa Foundation framework all these are included.

Categories : Objective C

Objective c - Multiple scrollviews inside a scrollview
Generally scrollview eats all the touch events. Hence the subviews of scrollview do not get touch events. To enable touch events in subviews you can pass the touch event to the next responder from scroll view. You can do that by over riding touches method in an scrollview subclass. Detailed explanation with example can be found here.

Categories : IOS

calling a method inside someClass from AppDelegate Objective-C IOS
Instantiate an instance of the class that you want to send the request from and make the method public (in the .h file). Then import that class into the app delegate and call it. Like so... YourClass * yourClassInstance = [[YourClass alloc] init]; [yourClassInstance someMethod]; in YourClass.h below the @interface you would declare the method like so -(void)someMethod; So anyone could access it.

Categories : Iphone

Objective C - Catch exception raised from inside a block
Don't be fooled by the fact that your block is specified inline with other code. You cannot catch exceptions in the block in the outer (non-block) code because the code in the TRY block has already executed (and exited) and the block only executes in it's own scope. A solution is to catch exceptions in the block.

Categories : IOS

Setting object property inside a block trouble on Objective-C
It's because the setting of JSONObjectsCollection happens asynchronously. So your method is returning JSONObjectsCollection before it is set. Thus, it might look like: - (void)retrieveAtEndpoint:(NSString *)endpointURL withRootNode:(NSString *)rootNode { NSURL *url = [NSURL URLWithString:[NSString stringWithFormat: endpointURL, fuegoWSURL]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSDictionary *dict = (NSDictionary *) JSON; [self setJSONObjectsCollection: [dict objectForKey:rootNode]]; // do here whatever you want to do now that you have your array, e.g.

Categories : Objective C

Acessing control in one window from another in WPF
You did not call .Show() on the MainWindow form variable named main. Also wondering why there is no Handles clause on your button's click event? Did you Addhandler that? Public Class Quicksites Dim main As New MainWindow Private Sub Button_Click(sender As Object, e As RoutedEventArgs) Handles Button.Click main.Show() main.WebBrowser1.Navigate("http://www.google.com") End Sub

Categories : Wpf

Acessing array from a function C++
If you want your dungeon to persist after the player saves and closes the program, you'll have to take your map data, player state, and everything and save it to a file. And then load it from the file rather than generating it randomly at startup. If you want your dungeon to persist, say, between floors that the player can travel up and down, it's still a valid idea to save the individual floors off to file and load them as needed. A side bonus that Nethack uses is that if the whole thing crashes, it can attempt to reconstruct the save from the last time you moved between floors. Alternatively, you can simply have your dungeon consist of an ever growing vector, or a 3D array, complete with x,y, and z coordinates. It's not so much a question about pointers as much as how to store data

Categories : Arrays

Surprising Failures Putting a C Array Inside an Objective-C Struct Property
While this may not directly answer your question, the answer is most likely found here: objc-accessors.mm A quick peek at it reveals the mechanisms by which Objective-C properties are synthesized, and this (somewhat troubling) header comment seems relevant. // This entry point was designed wrong. When used as a getter, src needs to be locked so that // if simultaneously used for a setter then there would be contention on src. // So we need two locks - one of which will be contended. void objc_copyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic, BOOL hasStrong)

Categories : Objective C

Acessing "a" element of an array using jquery
var al_normal = $("#tables a").get(0); or var al_normal = $("#tables a")[0]; Both return the DOM object. If you need to access it as a jQuery object, use: var al_normal = $("#tables a").eq(0); Further info: http://api.jquery.com/eq/

Categories : Jquery

dynamic ngmodel value in ngrepeat and acessing it
i think your binding is somehow messed up. Something like this should do it. Watch the console for the received objects and you can start doing stuff with them. http://plnkr.co/edit/ugtbO2 html <div ng-repeat="a in articles" ng-model="article"> <div class="description">{{a.description}} (id: {{a.id}})</div> <div class="commentbox"> <textarea placeholder="Share your View" ng-model="a.review"></textarea> <div class="post"> <button ng-click="addComment(a)" > Submit </button> </div> </div> </div> js $scope.articles = [ {id: '1',description: 'sdfsdf', review:''}, {id: '2',description: 'asa334', review:''}, {id: '3',description: 'dfsdfw3r', revi

Categories : Angularjs

Acessing dependency property in the same control xaml
Yes it is possible. something like: .xaml <UserControl x:Class="MvvmLight26.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:MvvmLight26" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserControl1}}, Path=CustomBackground}" /> </UserControl> and .xaml.cs: public partial class UserControl1 : UserControl { public static readonly DependencyProperty CustomBackgroundProperty =

Categories : Wpf

Issue with Acessing facebook page using restfb
I recently faced the similar issue. facebookClient.fetchObject("somePageName",Page.class) was throwing the exception you have mentioned. I noticed that the code runs properly for any page which is of the format A) facebook/somePageName however the pages with url like below do not work: B) facebook/pages/somePageName/2192383292 Any page which does not have a Page Username set in the PageInfo follows the type B url and is not accessible with the code. To resolve the issue, ask the page admin to edit the pageInfo and set a Username for the page. E.g for your case lets say the username specified is WellStartPauldingHospital. In that case the url to access the page will become https://www.facebook.com/WellStarPauldingHospital and you will be able to use the code as follows: Page page =

Categories : Facebook

Acessing javaScript array of objects like a matrix
No. Objects and Arrays are two very different types in JavaScript. In an Array order is very important but order is not retained for Object keys. Keep in mind you can still iterate over the keys of an Object. for (var prop in myObj) { console.log("myObj.prop -> ", myObj[prop]); }

Categories : Javascript

null refference at acessing multiple object in xml wit c#
XML element names are case sensitive. You have buttonaction in your XML, but buttonAction in your C# code. I would also recommend using string casts instead of .Value, as .Value will produce a NullReferenceException if an element is not found, and these can be hard to track down: select new Button() { texture = (string)button.Element("texture"), position = StringToVector((string)button.Element("position")), buttonAction = (string)button.Element("buttonaction") } You would also need to modify your StringToVector() method to be able to handle null values. This will make your code more resilient against NullReferenceExceptions.

Categories : C#

why mdpi devices not acessing images from drawable folder
You should store your images under drawable-nodpi folder. Also i want to know about the application deployment like if i put different images in different folder; does only that folder which is compatible to device is used while installation or all the folders are added. how it actually works. All images are installed, but only those are taken at runtime, which fit best to the current device configuration. Images from drawable-nodpi are density independent and can be used on every device as they are.

Categories : Android

Rails Carrierwave acessing parent model from within a version
Turns out you can't access the model variable from within a version but it's possible from within a custom method. As explained here: http://jackdempsey.me/how-to-access-the-model-in-a-version-in-carrierwave So instead I will have to move the if statement to within the image_crop method

Categories : Ruby On Rails

Wtforms Forms, Syntax for acessing embedded Formfield
There are project_name can be dict or object (not form object because it will populate InstituteForm.project_name with html tag values), so you can use next code: form = InstituteForm(institue_name="cambridge", project_name=dict(name="test name"), email=["email@gmail", "email@gmail"]) or class Project(object): name = "test" workflow = ["test1", "test2"] form = InstituteForm(institue_name="cambridge", project_name=Project(), email=["email@gmail", "email@gmail"]) or class Project(object): name = "test" workflow = ["test1", "test2"] class Institute(object): institue_name = "cambridge" project_name = Project() email = ["email@gmail", "email@gmail"] form = InstituteForm(obj=

Categories : Python

Bad request 400 error while acessing wcf rest service frequently
I'd be tempted to comment out that configuration line on the client and host, and then trying running it. That config seems to set minimums and performance limits. If that doesn't change anything, you might try setting the performance throttling. You could add this to the configuration and tinker with the settings until the performance of your web service smooths out. The default, for instance, for concurrent calls is 16, but if you raise that number using the ServiceThrottling, you might get better results. <serviceBehaviors> <behavior name="throttleThis"> <serviceMetadata httpGetEnabled="True" /> <serviceThrottling maxConcurrentCalls="40" maxConcurrentInstances="20" maxConcurrentSess

Categories : Wcf

why I am getting ExceptionInInitializerError while acessing Hashmap from constructor which is initialized in static block
Here is the problem: private static Check check = new Check(); and in the constructor you have System.out.println("Map Contains "+map.get("1")); So you've got a Catch-22 situation: you want the map to exist before the constructor has run, and you want the constructor to run before initializing the map. All you need to do is put the declaration of the check singleton below the static initializer which sets up the map. At that point the constructor will be safe to run. As a side note, make that check variable final. That's standard for singletons, and for a good reason: it guarantees that there will be only one instance.

Categories : Java

ios how to store time values in nsmutablearray and acessing objects from the array
Change that line to: double timeToBeUse=[[timer objectAtIndex:timeIndex] doubleValue]; In your original version, you are trying to create a new NSNumber with a NSNumber instead of creating a double value.

Categories : IOS

Removing a key from nsmutableDictionary in ios
Iterate through the dictionary and look for any null entries and remove them. NSMutableDictionary *prunedDictionary = [NSMutableDictionary dictionary]; for (NSString * key in [yourDictionary allKeys]) { if (![[yourDictionary objectForKey:key] isKindOfClass:[NSNull class]]) [prunedDictionary addObject:[yourDictionary objectForKey:key] forKey:key]; } After that, prunedDictionary should have all non-null items in the original dictionary.

Categories : IOS

NSMutableDictionary with accent
I think you need to encode this string first...This is unicode string which you are getting. You need to encode that to UTF8 string like this. char cString[] = "This isnu2019t your bike"; NSData *data = [NSData dataWithBytes:cString length:strlen(cString)]; NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"result string: %@", string); OR NSString *input = @"\u5404\u500b\u90fd"; NSString *convertedString = [input mutableCopy]; CFStringRef transform = CFSTR("Any-Hex/Java"); CFStringTransform((__bridge CFMutableStringRef)convertedString, NULL, transform, YES); NSLog(@"convertedString: %@", convertedString);

Categories : Objective C

self referencing NSMutableDictionary
I would be really surprised if this worked. When you set dict[@3]=dict, you are basically giving it an infinite loop to create an infinitely deep dictionary. When you create data from the dictionary, it seems to protect you from that by replacing the infinite dictionary with an uninitialized one so that the user's ram is not completely drained before the application crashes. If you were to try to print out dict[@3] in the console, the application would infinitely loop trying to print it out and would get stuck until it finally crashes sometime later. Hence, f you want to store your dictionary in a dictionary, create another one.

Categories : IOS

Update nsmutableDictionary insert a new key
You just have to call the setObject:forKey Adds a given key-value pair to the dictionary. - (void)setObject:(id)anObject forKey:(id < NSCopying >)aKey Parameters anObject The value for aKey. A strong reference to the object is maintained by the dictionary. Raises an NSInvalidArgumentException if anObject is nil. If you need to represent a nil value in the dictionary, use NSNull. aKey The key for value. The key is copied (using copyWithZone:; keys must conform to the NSCopying protocol). Raises an NSInvalidArgumentException if aKey is nil. If aKey already exists in the dictionary anObject takes its place. In your example you can call it like this: [yourMutableDictionary setObject:[NSNumberWithInt:10] forKey:@"ID"] also, remember th

Categories : Objective C

Only the last value of NSMutableDictionary is added to NSMutableArray
You erroneously use setValue instead of addObject. [arData addObject:mutableDictionary5]; This will work if you alloc init a new dictionary inside the loop. If you want to reduce the array to just titles do this after the loop: NSArray *titleArray = [arData valueForKeyPath:@"title"]; Now you have an array containing just titles. BTW, you could make some effort to invent better variable names. Note that by convention in Objective-C variable names start with low cap while class names are capitalized.

Categories : Iphone

Comparing NSArray values with NSMutableDictionary
You should use a recursive method (or function) which checks the dictionary it is passed and calls itself to process any sub dictionaries. The method should return anything it finds and anything found when it calls itself. If there should only be one result array (from one level) the method could return as soon as it is found or as soon as the result of calling itself is non-nil.

Categories : Objective C

Set value for key of a single NSMutableDictionary from an array of NSMutableArray
Call setObject:forKey:, not setValue:forKey:. There is a difference. Note that NSMutableArray extends NSArray so NSMutableArray has all of the methods of NSArray. I also recommend you split your line up as well as use modern syntax: NSMutableDictionary *dict = self.items[i]; dict[@"key"] = @"value";

Categories : IOS

iOS - NSMutableDictionary reverting to previous state?
Do you know how properties work in Objective-C 2.0? I would declare a property in your parentViewController to contain your _currentItemsArray, declared as a strong reference. @property (nonatomic,strong) NSMutableArray *_currentItemsArray; Also, set a weak property in your childViewController (the one you push to for deletion) @property (nonatomic, weak) NSMutableArray *parentItemsArray; Set the property on the childViewController upon push childViewController.parentItemsArray = self._currentItemsArray; [self.navigationController pushViewController:childViewController animated:YES]; Remove the item inside the array within childViewController instead of calling a method on your parentController [self.parentItemsArray removeObjectAtIndex:indexOfKey]; Doing this, you don't have

Categories : IOS

Grouping the NSArray elements into NSMutableDictionary
Create an NSMutableDictionary, then iterate through your 'group array'. For each NSString object: get the NSArray of componentsSeparatedByString:@"-" use the second component to create a key and retrieve the object for that key from your mutable dictionary. If its nil then set it to an empty NSMutableArray. add the original NSString to the mutable array.

Categories : IOS

Blocks, Thread-safety, and NSMutableDictionary
No, blocks are not always run on different threads. It depends entirely on what the block is and how you schedule it to be executed. Are you executing it yourself, adding it to an operation queue, using a GCD queue. The block could be run on any thread, including the main thread. You have control over whether it is run on the main thread or a background thread. ThreadSafety

Categories : Objective C

Same object saved to NSUserDefaults over and over again when the NSMutableDictionary is different
Whatever singleTrap is, you're repeatedly mutating it and storing another reference to the same object in your allTraps array. You need to create (instantiate) a new item for each entry you want in your allTraps list. It looks like singleTrap is an array of strings, so try: allTraps[idx] = [singleTrap copy];

Categories : IOS

NSMutableDictionary writeToFile fails with more than one item
ok, found the issue, it's a bug on my end, when I load the dictionary between saves, I convert to NSURL again and I forgot to reconvert it back to NSString on the second save... The debugger didn't catch it because it shows the same thumbnailURL description for NSURL and NSString...

Categories : IOS

Problems calling objective c @dynamic properties from objective c runtime
You can call the setter and getter methods indirectly by using the NSObject methods - [NSObject setValue:(id) forKey:(NSString *)]; - (id)[NSObject valueForKey:(NSString *)]; where the key is the property name, if the property is a primative type like unsigned long, double etc. Then the setValue and value methods will deal with NSNumber equivalents. Also you can call the property setter and getter the same way you call other methods, so you can use all of the dynamic method invocation features you can use with regular methods, thought you probable have already worked that out.

Categories : Objective C



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.