w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
NSMutableArray doesn't get XML values
Probably what you need to do is wait for the process to get completed and the block literally doesn't know what your doing inside it or i would say the inside function is not been captured by the block.so use the array(call the function which is using your array) only after block gets completed. Example: TBXMLSuccessBlock s = ^(TBXML *tbxml) { NSLog(@"yes"); // Do something with TBXML object "tbxml/add it ur array //Here you call the function which is about to use your array. }; //Not outside the block. EDIT : Refer this==> How do I avoid capturing self in blocks when implementing an API?

Categories : Iphone

Why NSMutableArray doesn't get sorted?
-sortedArrayUsingSelector: is actually an NSArray method that returns a new sorted array (which you promptly ignore). You mean to use -sortUsingSelector:, which is an NSMutableArray method that rearranges the existing array itself. It's pretty common in Cocoa to have one method for returning a modified immutable version of an object, and another method for modifying the mutable object itself (-stringByAppendingString: and -appendString:, for example).

Categories : Objective C

Changing values of element of NSMutableArray
If I understand what you are talking about, try this: Rather than use an array of arrays, why not use a dictionary of array and use the second member element of the array as the dictionary key. So something like this: NSMutableDictionary *dataBase = [[NSMutableDictionary alloc] init]; NSMutableArray *firstRow = [NSMutableArray arrayWithObjects:@(100), @"3379429411", @"Cont10", @(0), @(0), @(0), @(0),@"Name1",@"Name2",@"Name3",@"Name4",@"192.168.0.1",@(0),@(0),@(0),@(0), nil] atIndex: 0]; dataBase[firstRow[1]] = firstRow; That way when you need to replace a row all you have to do is: NSMutableArray *newRow = [self getNewRow]; dataBase[newRow[1]] = newRow;

Categories : IOS

NSMutableArray not retaining values outside of method
Your array is being populated asynchronously - you're downloading from a URL in the background while your user interface continues to run in the foreground. The reason you're seeing it as empty is because it hasn't been populated yet. Your app should be written in such a way that it can deal with data not being available instantaneously and being able to update itself when the data becomes available. If that doesn't get you on the right track, please ask a more specific question about the problem you're trying to solve.

Categories : Objective C

How can i count and sort a NSMutableArray duplicate values
A solution could be to simply query the counted set for the count of any object, to build an array that keep track of the counts: // This after having sorted the array: NSMutableArray* counts= [NSMutableArray arrayWithCapacity: array.count]; for(id object in array) { [counts addObject: @([countedSet countForObject: object]) ]; }

Categories : Objective C

how to append Values in NSMutableArray in Text View?
You can try instead - (void)viewDidLoad { NSMutableArray *array = [[NSMutableArray alloc]initWithObjects:@"figo",@"messi",@"totti",@"ronaldo",@"pirlo", nil]; [super viewDidLoad]; [text setText:[array componentsJoinedByString:@" "]; } or if you want them all in a line, separated by whatever character, you can just replace @" " and use yours. @", " would be ok, but also @" "

Categories : IOS

ObjC – Getting values from Objects in array(NSMutableArray)
it could go something like this (take into account that it could be written more compact, but that would mystify the code for a beginner): const int NR_ELEMENTS = 100; NSMutableArray *objects = [NSMutableArray arrayWithCapacity:NR_ELEMENTS]; for (int i=0; i < NR_ELEMENTS; i++) { MyClass *mc = [[MyClass alloc] initWith:i]; [objects addObject:mc]; } for (int i=0; i < NR_ELEMENTS; i++) { // Suppose MyClass.value is integer NSLog(@"%i ", [[objects objectAtIndex:i] value]); } Kind regards, PB

Categories : Java

Deep copy of an NSMutableArray of custom objects with NSMutableArray members
In order to deep copy the content of the array [[NSMutableArray alloc] initWithArray:srcArray copyItems:YES]; will send copyWithZone: to every object inside the collection. If they don't respond to this selector, you'll get a crash. Have your CustomParent class to conform to the NSCopying protocol and you're done. Here's some extra info on how do achieve it: Implementing NSCopying

Categories : IOS

pass NSMutableArray to another view giving null values
Better way is to create your NSMutableArray in Appdelegate file like below... @property (nonatomic, retain) NSMutableArray *animalArray;//define this in Appdelegate.h file synthesize it in Appdelegate.m file like @synthesize animalArray; Create Appdelegate object in prefix.pch file like below. #define AppDel ((AppDelegate *)[UIApplication sharedApplication].delegate) and import your Appdelegate file in prefix.pch like below.. #import "AppDelegate.h" now where you want to use that array...just write like below.. AppDel.animalArray=//you can do whatever you want with array.... By doing this no need to pass array to other view controller, you can use that global array in whole project ,you can insert object in that array in any class and can access in any class. Let me know i

Categories : Iphone

filtering objects from nsmutablearray with a nsarray of string values
Something like this: NSIndexSet *toRemove = [scoreBoard indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) { return [friends containsObject:obj.name]; }]; [scoreBoard removeObjectsAtIndexdes:toRemove]; Note this isn't optimally fast. You might also want to look at [NSMutableArray filterUsingPredicate:] although NSPredicate isn't my preference.

Categories : Xcode

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

conversion from NSMutableArray of NSData to NSMutableArray of NSString?
I am not aware of anyway besides visiting each element, like: NSMutableArray *mutableArray; // your array of objects for (int i = 0; i < [mutableArray count]; i++) mutableArray[i] = [[NSString alloc] initWithData:mutableArray[i] encoding:NSUTF8StringEncoding];

Categories : IOS

Xcode Add NSMutableArray to a NSMutableArray
The problem is that you shouldn't be using removeAllObjects as it just cleans the array out (deleting the work you just did). Instead, you should be creating a new array (tempImageArray = [NSMutableArray array];).

Categories : Objective C

Vlookup macro doesn't return all values needed but the values are input to pull from
A B C D E F 1 Adam 1 Adam 2 Peter 3 John 3 John 4 Phil 4 Phil 6 #N/A A B C D E F 1 Adam 1 Adam 6 Peter 2 Peter 3 John 3 John 4 Phil 4 Phil 6 Peter Cell D1 Contains the formula: =IF(ISERROR(INDEX(B:B,MATCH(C1,A:A,0))),INDEX(F:F,MATCH(C1,E:E,0)),INDEX(B:B,MATCH(C1,A:A,0))) Copy it down.

Categories : Excel

Inherited variable doesn't like new values
It's easy. You simply refers to constructor param, not the inherited variable. You may either rename constructor param, or refer to the var with this. prefix class Sub(titleP: String) extends Super(titleP) { def test = println(title) }

Categories : Scala

How to get values that doesn't pass from FilterIterator
I think you must rewrite the accept() mechanic. Instead of returning true or false, you may want to break down the array to $result = array( 'passed' => array(...), 'not_passed' => array(...) ); Your code may look like this if (strcasecmp($user['name'], $this->userFilter) == 0) { $result['not_passed'][] = $user; } else { $result['passed'][] = $user; } return $result;

Categories : PHP

JQuery UI Slider doesn't work with "value: x", only with "values: [x]"
this seems to work: $(document).ready(function () { $("#slider").slider(options = { range: "min", value: 50, min: 1, max: 100, slide: function (event, ui) { var delay = function () { var handleIndex = $(ui.handle).data('index.uiSliderHandle'); $("#slideText").html(ui.value).position({ my: 'center top', at: 'center bottom', of: ui.handle, offset: "0, -74" }); $(".sliderValue").val("$" + ui.value + "k"); }; setTimeout(delay, 0); }, create : function (event, ui){ $(".sliderValue").val("$" + options.value+ "k"); } }); }); A: use the create option as a callback function when the slider is done. the UI is empty

Categories : Jquery

static Map as cache loses or doesn't set values
I think I found what the problem is: My environment is a bit special as my web application consists of a Servlet/JSP-Frontend and an Axis 2 SOAP-service as backend. To optionally get rid of SOAP we decided to make the Axis 2 service available as a native Java class using some ClassLoader manipulations, especially using URLClassLoader with paths to our backends and all the libs we use etc. and load backend classes natively using URLClassLoader. java.lang.ClassLoader.loadClass says that normally findLoadedClass is used before a class is loaded to see if it already has been loaded before and don't load it again. This doesn't seem to be the case in my environment or how I use URLClassLoader, because each invocation to load a class during each request produced a new class object. Because of thi

Categories : Java

Angular.js's $compile doesn't replace values
As sza said, the solution is easy thanks to the $interpolate function: var template = 'Hello {{ name }}'; console.log($interpolate(template)({name: 'World'})); Console output is: Hello World

Categories : Angularjs

TreeMultimap doesn't allow null or empty values?
That's very deliberately how Multimap works. Putting an empty String and a normal String into a Multimap makes exactly no difference, and a Multimap will treat a key without any values as completely nonexistent. Please read Multimap Is Not A Map from the Guava wiki.

Categories : Java

Using toString method but the combo box still doesn't show values
Overriding toString method should work but is not a good practice. I suggest you implement a ListCellRenderer instead, something like this: public class MyCellRenderer extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if(value != null){ if(value instanceof Patient){ Patient p = (Patient) value; setText(p.getName()); } else { setText(value.toString()); } if(isSelected){ setBackground(...);//set background color when item is selected setForeground(...);//set foreground color when item is selected } else {

Categories : Java

My connection class doesn't read inputs values?
You don't set any values. This: AccessorClass s = new AccessorClass(); ... = ConnectionClass.Connection(s.DB, s.ID, s.Password); // ^^ ^^ ^^^^^^^^^ - no values in these Use an initialization list to set them: AccessorClass s = new AccessorClass() { DB = "Database", ID = "ID", Password = "Password" }; EDIT: Your update won't work either. You're creating an AccessorClass object, then calling a method. In that method.. you're new'ing up another AccessorClass. Do this: AccessorClass s = new AccessorClass (); s.DB = txtDatabase.Text; s.ID = txtID.Text; s.Password = txtPassword.Text; HelperClass.Get(s); // <--- pass the instance through Then change your HelperClass.Get function to this: public static void Get(AccessorClass s) {

Categories : C#

Array echo doesn't print values retrieved from SQL query
The problem is, is that your json object shows that $results is an array around an object. This is what you need to do to access a value in that object. <?php echo $results[0]->Descripcio_CAT; ?> If you want the object alone you can assign it to a variable <?php $object = $results[0]; echo $object->Descripcio_CAT; ?> Or if you will have a list of objects, you can use a foreach loop. <?php foreach($results as $object) { echo $object->Descripcio_CAT; } ?> If you just want to see the variable without knowing the contents you can var_dump it! <?php var_dump($results); ?>

Categories : PHP

Entity Framework - default values doesn't set in sql server table
I think this answers your question (but I don't know, if this is the answer you wanna read): How can I set default values in Entity Framework

Categories : C#

selectionArgs in SQLiteQueryBuilder doesn't work with integer values in columns
You need to convert your int id into string before passing to your query because the parameter array is of type string. For example: cursor = builder.query(db, new String[]{"col1", "col2", "col3"}, "id = ?", new String[]{String.valueOf(getSID(db))}, null, null, null); The reason why it works in second type of query is because you are appending the integer value with string which automatically converts the int into String. For example: int i = 10; String s = i + ""; //now 10 is in string

Categories : Android

anydbm module, values() , items() method doesn't work
It should work although it is not the real solution: import anydbm db = anydbm.open('cache2','c') db['www.python.org'] = 'python website' db['www.cnn.com'] = 'cable news network' for key in db.keys(): print key, db[key]

Categories : Python

Query returns what i want, but wwhen i put into array the array_sum() doesn't add up my values
Are you doing the array_sum() INSIDE the fetch loop? e.g. while($sInfo = fetch_from_db($result)) { $p_rate[] = $sInfo->p_rate; $rate = array_sum($p_rate); } ? If so, then you'll have to move the summation to OUTSIDE the loop, so it only sums up after you've retrieve all of the data from the DB: while($sInfo = fetch_from_db($result)) { $p_rate[] = $sInfo->p_rate; } $rate = array_sum($p_rate);

Categories : PHP

how to return comma separated values that DOESN'T exists in mysql table?
The one statement approach can work <?php //needs to be configured appropriately $conn = new PDO($dsn, $user, $password); // fetch associative arrays, I normally use objects myself though $conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); // split the string in question into words $wordsToTag = explode(" ", $phraseToTag); // create a holder for the common words $commonWords = array(); // prepare and execute the statement $stmt = $conn->prepare("SELECT word FROM tbl_general_words"); $stmt->execute(); // add the words to the array while($row = $stmt->fetch()) { $commonWords[] = $row['word']; } // get the words that are not common $wordsToTag = array_diff($commonWords, $wordsToTag); // build your SQL string $sql = "INSERT INTO tags (tag) VALUES "; // fore

Categories : PHP

Android + OpenCV: OnTouch getX(), getY() doesn't return right values
This is the solution to your problem. which is, @Override public boolean onTouch(View arg0,MotionEvent event) { double cols = mRgba.cols();// mRgba is your image frame double rows = mRgba.rows(); double xOffset = (mOpenCvCameraView.getWidth() - cols) / 2; double yOffset = (mOpenCvCameraView.getHeight() - rows) / 2; onClickX = (float)(event).getX() - xOffset; onClickY = (float)(event).getY() - yOffset;

Categories : Android

Excel - Is there a way to sort by matching values? (Note: Sorting Doesn't Work Here)
Your question isn't that clear, but if I got it right, you need vlookup() here. What I think I understood is (or something similar, do correct me if you meant otherwise): In one table, column A contains product names, and column B contains the products' corresponding UPC codes. In a second table, let's say another sheet named Sheet2, column A contains UPC codes with their corresponding inventory number. You want to get the corresponding inventory number of a certain product in the first table, with the only thing in common being the UPC code, and put this inventory number in column C of the first table. In this situation, you will put this formula in cell C2 of the first table (assuming that the first row contains headers): =VLOOKUP(B2, Sheet2!A:B, 2, 0) B2 contains the UPC code ex

Categories : Excel

How to add sum of NSMutableArray
This is because you keep re-creating your "scoreTally" array so it's constantly being reset to an array with a single NSNumber object. You need to create your "scoreTally" array once and then add additional objects to it as scores keep getting added. So I'd recommend moving your "scoreTally" creation somewhere else, for example the "viewDidLoad" method of your view controller (making sure to keep "scoreTally" around via an ivar or a property).

Categories : IOS

Min and Max Value of an NSMutableArray
You can get maximum and minimum number as below code. It may help you NSNumber * max = [array2 valueForKeyPath:@"@max.intValue"]; NSNumber * min = [array2 valueForKeyPath:@"@min.intValue"]; NSUInteger numberIndex1 = [array indexOfObject:min]; NSUInteger numberIndex2 = [array indexOfObject:max]; NSLog(@"Max Value = %d and index = %d",[max intValue],numberIndex1); NSLog(@"Min Value = %d and index = %d",[min intValue],numberIndex2);

Categories : Iphone

ios compare two NSMutableArray
Jason, I am not pretty sure about what your requirements are but as per I understand predicate is answer for your question, which are very helpful for searching. Block predicates have made it very easy to use. NSArray *allFbIds = [self.myPersonArray valueForKeyPath:@"UserDef2"]; NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { NSDictionary *data = (NSDictionary *)evaluatedObject; NSString *fbid = [data objectForKey:@"id"]; return [allFbIds containsObject:fbid]; }]; NSArray *filetr = [array filteredArrayUsingPredicate:predicate]; If any of fbID will be available in property UserDef2 in KP_PERSON object of myPersonArray that will be in the filtered in the array. I think this might solve your problem.

Categories : Iphone

IOS: save an NSMutableArray
You should read : https://developer.apple.com/library/mac/#documentation/cocoa/reference/foundation/Protocols/NSCoding_Protocol/Reference/Reference.html You need to implement initWithCoder and encodeWithCoder. To save to file, just do : [NSKeyedArchiver archiveRootObject:myArray toFile:@"someFile"]; to load it: NSMutableArray* myArray = [NSKeyedUnarchiver unarchiveObjectWithFile:@"someFile"];

Categories : IOS

NSMutableArray behaviour with ARC
If it's a copy then no. If you've added it as a reference then yes. It's just a pointer to an object so any changes to your object will apply to the object reference in the array. Don't be confused by the NSMutable part of the array. The same thing happens with a normal NSArray: if you change the object, then the array will have a reference to the changed object. The mutable part only applies to the array, not the objects in the array.

Categories : IOS

bool for key in NSMutableArray
Use index instead of key for an array. NSDictionary dictionary = (NSDictionary *)dataArray[0]; if ([(NSNumber *)[dictionary objectForKey:@"success"] boolValue]) { // ... }

Categories : Iphone

The two nsmutablearray value is getting swap with another in ios
Why are you checking tableView == pdfListnameTable ? That should be tableView isEqual:self. pdfListnameTable. Not sure that is relevant here, but if you have more than one tableView - i'd guess that you aren't switching to it as there seems to be a lack of an else statement for that.

Categories : IOS

NSMutableArray Resetting Itself?
There are good clues in your log output. There are multiple instances of the view controller (see the different values for 'self'?). They each have their own array. See this code... -(IBAction)newFileMenubar:(id)sender{ [newFileWindowControllerArray addObject:[[NewFileWindowController alloc]initWithWindowNibName:@"NewFileWindowController"]]; When you press the button associated with that action, your app builds another view controller and places it in the array. That view controller gets the awake from nib message and allocates another array, and so on. To confirm this, change the code as follows: -(IBAction)newFileMenubar:(id)sender{ [newFileWindowControllerArray addObject:@"Hello world"]; // and comment this out, for now: // [[newFileWindowControllerArra

Categories : Objective C

NSMutableArray add the last object only
Try something like this: - (NSMutableArray*) getFairInfoArray: (NSString*) FairIdForThisMethod From: (NSMutableArray*) exibitorsForThisMethod { NSMutableArray* exibitorsWithFairId = [[NSMutableArray alloc] init]; for (ExibitorInfo* currentExibitors1 in exibitorsForThisMethod) { if ([currentExibitors1.FairId isEqualToString: FairIdForThisMethod]) { ExibitorInfo* currentExibitors2 = [[ExibitorInfo alloc] init]; [currentExibitors2 setExibitorName:currentExibitors1.exibitorName]; [currentExibitors2 setStallLocation:currentExibitors1.stallLocation]; [currentExibitors2 setExibitorCellBackGround:currentExibitors1.exibitorCellBackGround]; [currentExibitors2 setCompanyLogoURL:currentExibitors1.companyLogoURL];

Categories : Iphone

NSMutableArray's objects are same
It is probably because you are using backlist.count-1 as your index instead of using i. try this: while (i!=backlist.count) { NSLog(@"%@ %@",[[backlist objectAtIndex:i] objectForKey:@"id" ],[[backlist objectAtIndex:i] objectForKey:@"name" ]);i++; }

Categories : Objective C



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