Search Results

Search found 1114 results on 45 pages for 'robert gould'.

Page 26/45 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Is it possible to transcode audio in C# using DirectSound?

    - by Robert Davis
    I want to transcode a lot of audio from its source format to PCM without resampling or messing with the sample size. I figure if Windows Media Player can play the file and it doesn't use a legacy ACM codecs it must be using DirectSound to do so (this is on Windows XP and Windows Server 2k3). So is it possible to access DirectSound from C# and do so? I've tried searching the web but all the examples have been about playback which I have no interest in doing.

    Read the article

  • Why can't I Bind a viewmodel property to a dependency property of a custom control

    - by Robert
    I want to use a color picker in my wpf application and I saw a nice looking one on this codeproject page. The control works fine until I want to connect the control to a viewmodel. I created a small test program with this viewmodel: public class ColorViewModel : ViewModelBase { public ColorViewModel() { LineColor = Brushes.Yellow; } SolidColorBrush _brushColor; public SolidColorBrush LineColor { get { return _brushColor; } set { _brushColor = value; RaisePropertyChanged(() => LineColor); } } } The test program has a textbox and the colorpicker controls: <StackPanel Orientation="Horizontal"> <TextBlock Text="Please Select a Color" FontWeight="Bold" Margin="10" Foreground="{Binding Path=LineColor, UpdateSourceTrigger=PropertyChanged}"/> <vw:ColorPickerControlView x:Name="ForeColorPicker" Margin="10" CurrentColor="{Binding Path=LineColor, UpdateSourceTrigger=PropertyChanged }"/> </StackPanel> In the loaded event of the window I set the viewmodel to the datacontext like this: DataContext = new ColorViewModel(); The problem is that I can't seem to bind the LineColor property of the viewmodel to the CurrentColor property of the ColorPickerControlView. The CurrentControl property of the ColorPickerControlView seems to be fine. The constructor looks like this: public ColorPickerControlView() { this.DataContext = this; InitializeComponent(); CommandBindings.Add(new CommandBinding(SelectColorCommand, SelectColorCommandExecute)); } In the constructor of the UserControl there is the line this.DataContext = this; I read that is is necessary to bind the dependency properties. Do I override this line when I set my viewmodel to the datacontext and is that why I can't bind to the CurrentColor property? Is there any workaround? Or did I make another mistake?

    Read the article

  • Unique element ID, even if element doesn't have one

    - by Robert J. Walker
    I'm writing a GreaseMonkey script where I'm iterating through a bunch of elements. For each element, I need a string ID that I can use to reference that element later. The element itself doesn't have an id attribute, and I can't modify the original document to give it one (although I can make DOM changes in my script). I can't store the references in my script because when I need them, the GreaseMonkey script itself will have gone out of scope. Is there some way to get at an "internal" ID that the browser uses, for example? A Firefox-only solution is fine; a cross-browser solution that could be applied in other scenarios would be awesome. Edit: If the GreaseMonkey script is out of scope, how are you referencing the elements later? They GreaseMonkey script is adding events to DOM objects. I can't store the references in an array or some other similar mechanism because when the event fires, the array will be gone because the GreaseMonkey script will have gone out of scope. So the event needs some way to know about the element reference that the script had when the event was attached. And the element in question is not the one to which it is attached. Can't you just use a custom property on the element? Yes, but the problem is on the lookup. I'd have to resort to iterating through all the elements looking for the one that has that custom property set to the desired id. That would work, sure, but in large documents it could be very time consuming. I'm looking for something where the browser can do the lookup grunt work. Wait, can you or can you not modify the document? I can't modify the source document, but I can make DOM changes in the script. I'll clarify in the question. Can you not use closures? Closuses did turn out to work, although I initially thought they wouldn't. See my later post. It sounds like the answer to the question: "Is there some internal browser ID I could use?" is "No."

    Read the article

  • How to do google webpage translate in a Java class

    - by Robert
    Hi,this is a follow-up question of mine. Suppose now I have a URL : http://www.baidu.com/s?bs=%B0%C2%B0%CD%C2%ED&f=8&wd=%B0%C2%B0%CD%C2%ED and it work perfectly by inputting it in the text field of google translate and select from "Chinese" to English. My question is ,suppose now I want to achieve this in Java, I would like to adopt "Process q=Runtime.getRuntime().exec( "cmd /c start +URL" approach to do this. Could I achieve that by simply concatenating the Google translate URL and the webpage URL? If yes,could you please elaborte,thanks.

    Read the article

  • Why do I get a NullReferenceException when using a style on a ContentPresenter?

    - by Robert Rossney
    I've created this template, which uses a style applied to the ContentPresenter so that I can bind the data object's Column property to Grid.Column, allowing the items to determine for themselves which column of the Grid they go into: <DataTemplate DataType="{x:Type local:MyObject}"> <ItemsControl ItemsSource="{Binding Items}"> <ItemsControl.Resources> <Style TargetType="{x:Type ContentPresenter}"> <Setter Property="Grid.Column" Value="{Binding Column}" /> </Style> </ItemsControl.Resources> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> </Grid> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </DataTemplate> When I run the program, I get a NullReferenceException. The beginning of the hilariously long stack trace: at System.Windows.StyleHelper.ApplyAutoAliasRules(OptimizedTemplateContent optimizedTemplateContent, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate, FrugalStructList`1& childRecordFromChildIndex, FrugalStructList`1& triggerSourceRecordFromChildIndex, FrugalStructList`1& resourceDependents, HybridDictionary& dataTriggerRecordFromBinding, Boolean& hasInstanceValues) at System.Windows.StyleHelper.ProcessTemplateContent(FrameworkTemplate frameworkTemplate, FrugalStructList`1& childRecordFromChildIndex, FrugalStructList`1& triggerSourceRecordFromChildIndex, FrugalStructList`1& resourceDependents, ItemStructList`1& eventDependents, HybridDictionary& dataTriggerRecordFromBinding, HybridDictionary childIndexFromChildID, Boolean& hasInstanceValues) at System.Windows.StyleHelper.SealTemplate(FrameworkTemplate frameworkTemplate, Boolean& isSealed, FrameworkElementFactory templateRoot, TriggerCollection triggers, ResourceDictionary resources, HybridDictionary childIndexFromChildID, FrugalStructList`1& childRecordFromChildIndex, FrugalStructList`1& triggerSourceRecordFromChildIndex, FrugalStructList`1& containerDependents, FrugalStructList`1& resourceDependents, ItemStructList`1& eventDependents, HybridDictionary& triggerActions, HybridDictionary& dataTriggerRecordFromBinding, Boolean& hasInstanceValues, EventHandlersStore& eventHandlersStore) at System.Windows.FrameworkTemplate.Seal() at System.Windows.StyleHelper.UpdateTemplateCache(FrameworkElement fe, FrameworkTemplate oldTemplate, FrameworkTemplate newTemplate, DependencyProperty templateProperty) at System.Windows.Controls.ContentPresenter.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) ...etc. It's not the binding. I still get the error if I explicitly set the value in the style's setter to 0, say. And the error vanishes if I remove the style, though then all of the items end up in column 0. What's going on here? And how do I debug a problem like this?

    Read the article

  • Require-Bundle and Import-Package versus feature.xml requires

    - by Robert Munteanu
    When building an Eclipse plugin (lato sensu) which consists of multiple plugins and one feature, I have two ways of specifying dependencies: in the plugins themselves, using Require-Bundle and Import-Package in META-INF/MANIFEST.MF; in the feature.xml file from the feature. In my understanding, it should be enough to declare the dependencies at the lower level, i.e. in the plugins. Why do we still have the feature.xml requires mechanism?

    Read the article

  • iPhone - UIView Animation on UIButton - button unclickable for portion of duration.

    - by Robert
    I am trying to have a button move around the screen and still be clickable. I have it moving around the screen correctly, but the odd thing is that I can't click the button until the final second of the animation. The button is still moving and yet after a certain threshold I can click it. Any idea what is happening? Any idea for some other way I can do what I want? Thanks for any help.

    Read the article

  • Bind postback data from a strong type view of type List<T>

    - by Robert Koritnik
    I have a strong type view of type List<List<MyViewModelClass>> The outer list will always have two lists of List<MyViewModelClass>. For each of the two outer lists I want to display a group of checkboxes. Each set can have an arbitrary number of choices. My view model class looks similar to this: public class MyViewModelClass { public Area Area { get; set; } public bool IsGeneric { get; set; } public string Code { get; set; } public bool IsChecked { get; set; } } So the final view will look something like: Please select those that apply: First set of choices: x Option 1 x Option 2 x Option 3 etc. Second set of choices: x Second Option 1 x Second Option 2 x Second Option 3 x Second Option 4 etc. Checkboxes should display MyViewModelClass.Area.Name, and their value should be related to MyViewModelClass.Area.Id. Checked state is of course related to MyViewModel.IsChecked. Question I wonder how should I use Html.CheckBox() or Html.CheckBoxFor() helper to display my checkboxes? I have to get these values back to the server on a postback of course. I would like to have my controller action like one of these: public ActionResult ConsumeSelections(List<List<MyViewModelClass>> data) { // process data } public ActionResult ConsumeSelections(List<MyViewModelClass> first, List<MyViewModelClass> second) { // process data } If it makes things simpler, I could make a separate view model type like: public class Options { public List First { get; set; } public List Second { get; set; } } As well as changing my first version of controller action to: public ActionResult ConsumeSelections(Options data) { // process data }

    Read the article

  • Setting the Identity/Principal from a MessageInspector in WCF

    - by Robert Wagner
    I am developing a WCF service that receives the user's credentials in the SOAP header. These credentials are read on the server side using a MessageInspector. So far so good. I want to set the Thread.CurrentPrincipal to a custom principal (CustomPrincipal), but when I do this from the MessageInspector, it gets overridden by the time the service is invoked. When is the best time to set the principal? Also what is the best way to pass the principal, identity or credentials from the inspector to that location?

    Read the article

  • SharePoint 2007 Publishing site and Audience Targeting in Web Part

    - by Robert Vukovic
    In a Publishing site I have web part that has to show news items from the list that has Audience Targeting field. I am using CAML query to retrieve small number of last news items. Is it possible to specify Target Audience in the CAML query ? If not, how should I do it ? Retrieve all results and than apply filter in a loop ? I am practically duplicating Content Query Web Part and I need Audience Targeting in my custom web part.

    Read the article

  • regular expression to get the filename from urls

    - by robert
    if i have a textbox with severals urls rapidshare.com/files/379028801/Fringe.S02E19.HDTV.XviD-LOL.avi rapidshare.com/files/379182651/Fringe.S02E19.720p.HDTV.X264-DIMENSION.mkv rapidshare.com/files/379180004/Fringe.S02E19.720p.HDTV.X264-DIMENSION.part1.rar rapidshare.com/files/379180444/Fringe.S02E19.720p.HDTV.X264-DIMENSION.part2.rar rapidshare.com/files/379181251/Fringe.S02E19.720p.HDTV.X264-DIMENSION.part3.rar rapidshare.com/files/379181743/Fringe.S02E19.720p.HDTV.X264-DIMENSION.part4.rar i need a the files name and its urls textbox2.text = Fringe.S02E19.HDTV.XviD-LOL.avi from here rapidshare.com/files/379028801/Fringe.S02E19.HDTV.XviD-LOL.avi Fringe.S02E19.720p.HDTV.X264-DIMENSION.part1.rar from here rapidshare.com/files/379180004/Fringe.S02E19.720p.HDTV.X264-DIMENSION.part1.rar and so on Thanks :)

    Read the article

  • C# Silverlight - XmlDictionary from Uri

    - by Robert White
    I've been developing a Silverlight application for a company's website and have encountered a problem. Up until now I have been programming this locally, now I need to publish the program onto the website; the issue is that FileStream can only access local files with elevated permissions. Here's a snippet of code: using (FileStream fileStream = new FileStream(@"E:\Users\LUPUS\Documents\Visual Studio 2010\Projects\Lycaon5\Lycaon5\acids.xdb", FileMode.Open)) { using (XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(fileStream, XmlDictionaryReaderQuotas.Max)) { //Read the XML file out. } } Without changing anything to do with XmlDictionaryReader reader - How could I go about reading the files from a relative Uri? Many Thanks, Rob. P.s. Apologies for the lack of formatting, me cave man, me don't know how.

    Read the article

  • Obtaining Current Fiscal Year from Hierarchy with MDX

    - by Robert Iver
    I'm building a report in Reporting Services 2005 based on a SSAS 2005 cube. The basic idea of the report is that they want to see sales for this fiscal year to date vs. last year sales year to date. It sounds simple, but being that this is my first "real" report based on SSAS, I'm having a hell of a time. First, how would one calculate the current fiscal year, quarter, or month. I have a Fiscal Date Hierarchy with all that information in it, but I can't figure out how to say: "Based on today's date, find the current fiscal year, quarter, and month." My second, but slightly smaller problem, is getting last years sales vs. this years sales. I have seen MANY examples on how to do this, but they all assume that you select the date manually. Since this is a report and will run pretty much on it's own, I need a way to insert the "current" fiscal year, quarter, and month into the PERIODSTODATE or PARALLELPERIOD functions to get what I want. So, I'm begging for your help on this one. I have to have this report done by tomorrow monring and I'm beginning to freak out a bit. Thanks in advance.

    Read the article

  • How does the destructor know when to activate itself? Can it be relied upon?

    - by Robert Mason
    Say for example i have the following code (pure example): class a { int * p; public: a() { p = new int; ~a() { delete p; } }; a * returnnew() { a retval; return(&retval); } int main() { a * foo = returnnew(); return 0; } In returnnew(), would retval be destructed after the return of the function (when retval goes out of scope)? Or would it disable automatic destruction after i returned the address and i would be able to say delete foo; at the end of main()? Or, in a similar vein (pseudocode): void foo(void* arg) { bar = (a*)arg; //do stuff exit_thread(); } int main() { while(true) { a asdf; create_thread(foo, (void*)&asdf); } return 0; } where would the destructor go? where would i have to say delete? or is this undefined behavior? Would the only possible solution be to use the STL referenced-counted pointers? how would this be implemented? Thank you- i've used C++ for a while but never quite been in this type of situation, and don't want to create memory leaks.

    Read the article

  • Looping through recordset with VBA

    - by Robert
    I am trying to assign salespeople (rsSalespeople) to customers (rsCustomers) in a round-robin fashion in the following manner: Navigate to first Customer, assign the first SalesPerson to the Customer. Move to Next Customer. If rsSalesPersons is not at EOF, move to Next SalesPerson; if rsSalesPersons is at EOF, MoveFirst to loop back to the first SalesPerson. Assign this (current) SalesPerson to the (current) Customer. Repeat step 2 until rsCustomers is at EOF (EOF = True, i.e. End-Of-Recordset). It's been awhile since I dealt with VBA, so I'm a bit rusty, but here is what I have come up with, so far: Private Sub Command31_Click() 'On Error GoTo ErrHandler Dim intCustomer As Integer Dim intSalesperson As Integer Dim rsCustomers As DAO.Recordset Dim rsSalespeople As DAO.Recordset Dim strSQL As String strSQL = "SELECT CustomerID, SalespersonID FROM Customers WHERE SalespersonID Is Null" Set rsCustomers = CurrentDb.OpenRecordset(strSQL) strSQL = "SELECT SalespersonID FROM Salespeople" Set rsSalespeople = CurrentDb.OpenRecordset(strSQL) rsCustomers.MoveFirst rsSalespeople.MoveFirst Do While Not rsCustomers.EOF intCustomers = rsCustomers!CustomerID intSalesperson = rsSalespeople!SalespersonID strSQL = "UPDATE Customers SET SalespersonID = " & intSalesperson & " WHERE CustomerID = " & intCustomer DoCmd.RunSQL (strSQL) rsCustomers.MoveNext If Not rsSalespeople.EOF Then rsSalespeople.MoveNext Else rsSalespeople.MoveFirst End If Loop ExitHandler: Set rsCustomers = Nothing Set rsSalespeople = Nothing Exit Sub ErrHandler: MsgBox (Err.Description) Resume ExitHandler End Sub My tables are defined like so: Customers --CustomerID --Name --SalespersonID Salespeople --SalespersonID --Name With ten customers and 5 salespeople, my intended result would like like: CustomerID--Name--SalespersonID 1---A---1 2---B---2 3---C---3 4---D---4 5---E---5 6---F---1 7---G---2 8---H---3 9---I---4 10---J---5 The above code works for the intitial loop through the Salespeople recordset, but errors out when the end of the recordset is found. Regardless of the EOF, it appears it still tries to execute the rsSalespeople.MoveFirst command. Am I not checking for the rsSalespeople.EOF properly? Any ideas to get this code to work?

    Read the article

  • Beginner questions on Java Regular Expression

    - by Robert
    Hello everyone. I began studying Java Regular Expression recently and I found some really intersting task.For example,I now need to dig out "Product Name","Product Description" and "Sellers for this product" out of the following HTML code.(I am sorry for the big chunck of code,but it is very straightforward) <td class="sr-check"> <input type="checkbox" name="cptitle" value="678560038" /></td> <td class="sr-image" style="width: 80px;"><a href="/Nikon-D300S-12-3-678560038/prices-html" class="strictRule" rel="nofollow"><img src="http://img01.static-nextag.com/image/Nikon-D300S-12-3-MP-Digital-SLR-Camera-Body-Black/0/000/006/789/461/678946110.jpg" alt="Nikon D300S 12.3 MP Digital SLR Camera Body - Black" class="imageLink strictRule" height="75" width="75" id="opILink_0" title="Nikon Digital Cameras - Nikon D300S 12.3 MP Digital SLR Camera Body - Black" /></a><div class="breaker">&nbsp;</div></td> <td class="sr-info"> <div class="sr-info"> <a id="opPNLink_0" class="underline" style="font-size:16px" href="/Nikon-D300S-12-3-678560038 /prices-html" >Nikon D300S 12.3 MP <b>Digital</b> SLR <b>Camera</b> Body - Black</a> <div class="sr-subinfo"> <div class="sr-info-description">SLR - 13.1MP, 12.3MP - 1x Optical Zoom - CompactFlash, SD/MMC Memory Card - 3in.</div> <div class="rating"> <img src="http://img01.static-nextag.com/imagefiles/stars/stars4_10px.gif" alt="4/5 stars" title="4/5 stars" /> (92 user ratings)</div> <div style="clear: both;"> <!-- nxtginc=nextag.api.ServerInclude$JSPIncludeWriter(/buyer/ATLSSI.jsp?ptid=678560038&dts=y) --> <a id="_atl_0" style="" href="http://www.nextag.com/serv/main/buyer/MyPDir.jsp?list=_transCookieList&amp;cmd=add&amp;ptitle=678560038" rel="nofollow">+ Add to Shopping List</a> &nbsp;|&nbsp; <!-- endnxtginc --> <a rel="nofollow" id="mltLink_0" class="mlt-link" href="/Digital-Cameras--zz500001z2z678560038zB2dgz5---html">See More Like This</a> </div> <div id="fsLink_0" class="featuredSeller"> <a rel="nofollow" class="featuredSeller" id="opFSLink_0_0" href="/norob/PtitleSeller.jsp?chnl=main&amp;tag=785646073amp;ctx=x%2BN%2Fs9zy56l4u8RXCzALE1jeLesDMzeK09rPQEdK3Yjx395ZzX9cMh9N5JAxjk7xPqF9hjk2ztM5IRXU5nspLubIXYaVzI%2B%2Fg7h1Qz58TzgvrWuNawV8qEIqqSmClArWMq6mpzNRuSlgg2xCXYObNnaIH00iKSUmBawDRvecwbCpAxhXgXoLEiEinTwr3EipComdzxL9UHFYTLoWUToUB5SRSsolQmEJ3mgnnvu83%2FC8W34TGpN9mJo%2BnyAeTkt4&amp;ptitle=678560038" target="_blank" >Thundercameras</a>:$1,289 &nbsp; <a rel="nofollow" class="featuredSeller" id="opFSLink_0_1" href="/norob/PtitleSeller.jsp?chnl=main&amp;tag=797076595&amp;ctx=x%2BN%2Fs9zy56l4u8RXCzALE1jeLesDMzeK09rPQEdK3Yjx395ZzX9cMh9N5JAxjk7xPqF9hjk2ztM5IRXU5nspLubIXYaVzI%2B%2Fg7h1Qz58TzgvrWuNawV8qEIqqSmClArWMq6mpzNRuSlgg2xCXYObNrcWLhL%2BhryuAGhXNhYSPE%2BpAxhXgXoLEiEinTwr3EipComdzxL9UHFYTLoWUToUB5SRSsolQmEJ3mgnnvu83%2FC8W34TGpN9mJo%2BnyAeTkt4&amp;ptitle=678560038" target="_blank" >PhotoVideoSuperStore</a>:$1,269 &nbsp; <a rel="nofollow" class="featuredSeller" id="opFSLink_0_2" href="/norob/PtitleSeller.jsp?chnl=main&amp;tag=803555293&amp;ctx=x%2BN%2Fs9zy56l4u8RXCzALE1jeLesDMzeK09rPQEdK3Yjx395ZzX9cMh9N5JAxjk7xPqF9hjk2ztM5IRXU5nspLubIXYaVzI%2B%2Fg7h1Qz58TzgvrWuNawV8qEIqqSmClArWMq6mpzNRuSlgg2xCXYObNt06qcvLJ5UQz7S3zKd4urWpAxhXgXoLEiEinTwr3EipComdzxL9UHFYTLoWUToUB5SRSsolQmEJ3mgnnvu83%2FC8W34TGpN9mJo%2BnyAeTkt4&amp;ptitle=678560038" target="_blank" >Digitalelect</a>:$1,279 &nbsp;</div> I would think of : (1) digging out the product name from <td class="sr-image >tag,and using regular expression exp ="<td><span\\s+class=\"sr-image\"[^>]*>" + ".*?</span><a href=\"" + "([^\"]+)" + "\"[^>]*>" + "([^<]+)" + "</a>.*?</td>"; (2) digging out the product info from the <div class="sr-info-description"> tag. exp = "<div class="sr-info-description"> [^>]*>" (3) digging out the Sellers' names from <div id="fsLink_0" class="featuredSeller"> tag. exp = "<div id="fslink_0" class="featuredSeller[^>]*>" + ".*?</span><a rel=\"" + "([^\"]+)" + "\"[^>]*>" + "([^<]+)" + "</a>.*?</td>"; I am just beginning learing using Java Regular Expression,I would be grateful if you could correct me if I am in the wrong track or my regular expressiona are wrong. Thanks a lot,guys.

    Read the article

  • iPhone - Memory Management - Using Leaks tool and getting some bizarre readings.

    - by Robert
    Hey all, putting the finishing touches on a project of mine so I figured I would run through it and see if and where I had any memory leaks. Found and fixed most of them but there are a couple of things regarding the memory leaks and object alloc that I am confused about. 1) There are 2 memory leaks that do not show me as responsible. There are 8 leaks attributed to AudioToolbox with the function being RegisterEmbeddedAudioCodecs(). This accounts for about 1.5 kb of leaks. The other one is detected immediately when the app begins. Core Graphics is responsible with the extra info being open_handle_to_dylib_path. For the audio leak I have looked over my audio code and to me it seems ok. self.musicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:songFilePath] error:NULL]; [musicPlayer prepareToPlay]; [musicPlayer play] is called later on in a function. 2) Is it normal for there to be a spike in Object Allocation whenever a new view or controller is presented? My total memory usage is very, very low except for whenever I present a view controller. It spikes then immediately goes back down. I am guessing that this is just the phone handling all the information for switching or something. Blegh. Wall of text. Thanks in advance to anyone who helps! =)

    Read the article

  • How do I split an NSString by each character in the string?

    - by Robert Höglund
    I have the following code, which works as I expect. What I would like to know if there is an accepted Cocoa way of splitting a string into an array with each character of the string as an object in an array? - (NSString *)doStuffWithString:(NSString *)string { NSMutableArray *stringBuffer = [NSMutableArray arrayWithCapacity:[string length]]; for (int i = 0; i < [string length]; i++) { [stringBuffer addObject:[NSString stringWithFormat:@"%C", [string characterAtIndex:i]]]; } // doing stuff with the array return [stringBuffer componentsJoinedByString:@""]; }

    Read the article

  • What to do of exceptions when implementing java.lang.Iterator

    - by Vincent Robert
    The java.lang.Iterator interface has 3 methods: hasNext, next and remove. In order to implement a read-only iterator, you have to provide an implementation for 2 of those: hasNext and next. My problem is that these methods does not declare any exceptions. So if my code inside the iteration process declares exceptions, I must enclose my iteration code inside a try/catch block. My current policy has been to rethrow the exception enclosed in a RuntimeException. But this has issues because the checked exceptions are lost and the client code no longer can catch those exceptions explicitly. How can I work around this limitation in the Iterator class? Here is a sample code for clarity: class MyIterator implements Iterator { @Override public boolean hasNext() { try { return implementation.testForNext(); } catch ( SomethingBadException e ) { throw new RuntimeException(e); } } @Override public boolean next() { try { return implementation.getNext(); } catch ( SomethingBadException e ) { throw new RuntimeException(e); } } ... }

    Read the article

  • Vim + OmniCppComplete: Completing on Class Members which are STL containers

    - by Robert S. Barnes
    Completion on class members which are STL containers is failing. Completion on local objects which are STL containers works fine. For example, given the following files: // foo.h #include <string> class foo { public: void set_str(const std::string &); std::string get_str_reverse( void ); private: std::string str; }; // foo.cpp #include "foo.h" using std::string; string foo::get_str_reverse ( void ) { string temp; temp.assign(str); reverse(temp.begin(), temp.end()); return temp; } /* ----- end of method foo::get_str ----- */ void foo::set_str ( const string &s ) { str.assign(s); } /* ----- end of method foo::set_str ----- */ I've generated the tags for these two files using: ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q . When I type temp. in the cpp I get a list of string member functions as expected. But if I type str. omnicppcomplete spits out "Pattern Not Found". I've noticed that the temp. completion only works if I have the using std::string; declaration. How do I get completion to work on my class members which are STL containers? Edit I found that completion on members which are STL containers works if I make the follow modifications to the header: // foo.h #include <string> using std::string; class foo { public: void set_str(const string &); string get_str_reverse( void ); private: string str; }; Basically, if I add using std::string; and then remove the std:: name space qualifier from the string str; member and regenerate the tags file then OmniCppComplete is able to do completion on str.. It doesn't seem to matter whether or not I have let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] set in the .vimrc. The problem is that putting using declarations in header files seems like a big no-no, so I'm back to square one.

    Read the article

  • Output to jTextArea in realtime

    - by Robert
    I have some code which takes a few minutes to process, it has to connect to the web for each string in a long array, each string is a url. I want to make it so that everytime it connects, it should refresh the jtextarea so that the user is not staring into a blank page that looks frozen for 20 min. or however long it takes. here is an example of something i tried and didnt work: try { ArrayList<String> myLinks = LinkParser.getmyLinksArray(jTextArea1.getText()); for (String s : myLinks) { jTextArea2.append(LinkChecker.checkFileStatus(s) + "\n"); } } catch (IOException ex) { JOptionPane.showMessageDialog(jTextArea1, "Parsing Error", "Parsing Error", JOptionPane.ERROR_MESSAGE); Logger.getLogger(MYView.class.getName()).log(Level.SEVERE, null, ex); }

    Read the article

  • Linq to Entities and outer joins issue

    - by Robert Koritnik
    Can somebody tell me, why does Linq to Entities translate many to 1 relationships to left outer joins instead of inner joins? It relation was many to 0..1. There's referential constraint on DB itself, that ensures there's a record in the right table, so inner join should be used instead. Is it possible to write LINQ in a way so they will translate to inner joins rather than left outer joins. It would speed query execution a lot.

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >