Daily Archives

Articles indexed Sunday June 6 2010

Page 3/76 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do I use a UIView subclass as a container?

    - by dxq
    I'm trying to subclass UIView to create a custom view that is essentially a container. The subclass contains a UILabel and a UIImageView- I can't make either of them show up. Here's an example of what I've been trying: In my main view controller: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { ViewClass *myView = [[ViewClass alloc] initWithFrame:CGRectMake(100, 100, 150, 150)]; [view addSubview:myView]; } return self; } In my UIView subclass: - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { UILabel *word = [[[UILabel alloc] initWithFrame:[self bounds]] autorelease]; word.text = @"WHY ISN'T THIS SHOWING UP!?"; [self addSubview:word]; } return self; } Can anyone explain what I'm doing wrong? I'm way out of practice with UIKit and Obj-C, and I figure I'm probably missing something obvious.

    Read the article

  • iphone OS 3.1.3 requires snow leopard upgrade

    - by unsorted
    itunes asked me to upgrade my iphone's OS to 3.1.3, so I complied naively. then xcode told me that the latest iphone OS version it could support was 3.1.2. So I went to download a new version from https://developer.apple.com/iphone/index.action#downloads, xcode 3.2.2 with iphone SDK. but when i went to install that, i was told I needed snow leopard 10.6.2 or later. so I'm just making sure that I am not misinterpreting anything when I say that, given that it is impossible to downgrade iphone OS versions without jailbreaking, I need to install a new version of the OS just so I can resume testing apps on my iphone?

    Read the article

  • Is it possible to implement bitwise operators using integer arithmetic?

    - by Statement
    Hello World! I am facing a rather peculiar problem. I am working on a compiler for an architecture that doesn't support bitwise operations. However, it handles signed 16 bit integer arithmetics and I was wondering if it would be possible to implement bitwise operations using only: Addition (c = a + b) Subtraction (c = a - b) Division (c = a / b) Multiplication (c = a * b) Modulus (c = a % b) Minimum (c = min(a, b)) Maximum (c = max(a, b)) Comparisons (c = (a < b), c = (a == b), c = (a <= b), et.c.) Jumps (goto, for, et.c.) The bitwise operations I want to be able to support are: Or (c = a | b) And (c = a & b) Xor (c = a ^ b) Left Shift (c = a << b) Right Shift (c = a b) (All integers are signed so this is a problem) Signed Shift (c = a b) One's Complement (a = ~b) (Already found a solution, see below) Normally the problem is the other way around; how to achieve arithmetic optimizations using bitwise hacks. However not in this case. Writable memory is very scarce on this architecture, hence the need for bitwise operations. The bitwise functions themselves should not use a lot of temporary variables. However, constant read-only data & instruction memory is abundant. A side note here also is that jumps and branches are not expensive and all data is readily cached. Jumps cost half the cycles as arithmetic (including load/store) instructions do. On other words, all of the above supported functions cost twice the cycles of a single jump. Some thoughts that might help: I figured out that you can do one's complement (negate bits) with the following code: // Bitwise one's complement b = ~a; // Arithmetic one's complement b = -1 - a; I also remember the old shift hack when dividing with a power of two so the bitwise shift can be expressed as: // Bitwise left shift b = a << 4; // Arithmetic left shift b = a * 16; // 2^4 = 16 // Signed right shift b = a >>> 4; // Arithmetic right shift b = a / 16; For the rest of the bitwise operations I am slightly clueless. I wish the architects of this architecture would have supplied bit-operations. I would also like to know if there is a fast/easy way of computing the power of two (for shift operations) without using a memory data table. A naive solution would be to jump into a field of multiplications: b = 1; switch (a) { case 15: b = b * 2; case 14: b = b * 2; // ... exploting fallthrough (instruction memory is magnitudes larger) case 2: b = b * 2; case 1: b = b * 2; } Or a Set & Jump approach: switch (a) { case 15: b = 32768; break; case 14: b = 16384; break; // ... exploiting the fact that a jump is faster than one additional mul // at the cost of doubling the instruction memory footprint. case 2: b = 4; break; case 1: b = 2; break; }

    Read the article

  • Trouble dragging and dropping gui components onto other .net forms using NHibernate

    - by IsaacB
    Hi, using VS2008, here. I have a GUI component that loads some stuff from a database mapped by nhibernate in its constructor. When I drag and drop this component onto another form from the toolbox, NHibernate complains that it can't find the config file in program files\visual studio 9\common7\ide. Why is it looking here for the cfg file? I'm actually calling database stuff through another project in the same solution, and the cfg file is located at the root of that project. copy/pasting the cfg file over to there does work, but I'm working with svn here and I don't want to have configuration files outside the repository. Something else that would help would be turning off how it tries to load the data in the form design screen. How would I do that?

    Read the article

  • read url in binary mode in java

    - by Andrew Zawok
    In java I need to read a binary file from a site and write it to a disk file. This example http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html could read webpages succesfully, but when I try to read a binary file from my localhost server and write it to a disk file the contents change, corrupting the binary file. Using fc I see that 0x90 is changed to 0x3F and other changes. How do I acess the binary files (read url and write to file) without java or anything else changing ANY characters, like doing any newline conversions or character conversions or anything else, simply reading input url and writing it out as a file.

    Read the article

  • Android AlertDialog with dynamically changing text on every request

    - by Ulrich Scheller
    I want to show an AlertDialog with one option that might change on every request. So for example at one time I want to show the option "add to contacts" while another time it should be "remove from contacts". My code does work on the first time, however Android seems to cache the AlertDialog so that onCreateDialog is not executed next time. Therefore the option doesnt change anymore. Can I prevent this caching, or is there just another way of changing the option? I am working with SDK 1.5 but using 1.1. @Override protected Dialog onCreateDialog(final int id) { ... String add_remove_contact = res.getString(R.string.profile_add_to_contacts); if (user.getContacts().contains(profileID)) { add_remove_contact = res.getString(R.string.profile_remove_from_contacts); // TODO: this string is not changed when contact status changes } final CharSequence[] items = {res.getString(R.string.view_profile), res.getString(R.string.profile_send_message), add_remove_contact}; AlertDialog.Builder builder = new AlertDialog.Builder(this); ... return builder.create(); }

    Read the article

  • Using java2d user space measurements with TextLayout and LineBreakMeasurer

    - by Andrew Wheeler
    I have a java2d image defined in user space (mm) to print an identity card. The transformation to pixels is by using an AffineTransform for the required DPI (Screen or print). I want to wrap text across several lines but the the TextLayout does not respect user space co-ordinates. private void drawParagraph(Graphics2D g2d, Rectangle2D area, String text) { LineBreakMeasurer lineMeasurer; AttributedString string = new AttributedString(text); AttributedCharacterIterator paragraph = string.getIterator(); int paragraphStart = paragraph.getBeginIndex(); int paragraphEnd = paragraph.getEndIndex(); FontRenderContext frc = g2d.getFontRenderContext(); lineMeasurer = new LineBreakMeasurer(paragraph, frc); float breakWidth = (float)area.getWidth(); float drawPosY = (float)area.getY(); float drawPosX = (float)area.getX(); lineMeasurer.setPosition(paragraphStart); while (lineMeasurer.getPosition() < paragraphEnd) { TextLayout layout = lineMeasurer.nextLayout(breakWidth); drawPosY += layout.getAscent(); layout.draw(g2d, drawPosX, drawPosY); drawPosY += layout.getDescent() + layout.getLeading(); } } The above code determines font metrics using user space sizing of the Font and thus turn out rather large. The font size is calculated as best vertical fit for the number of lines in an area with the calculation as below. E.g. attr.put(TextAttribute.SIZE, (geTextArea().getHeight() / noOfLines - LINE_SPACING) ); When using g2d.drawString("Some text to display", x, y); the font size appears correct. Does anyone have a better way of doing text layout in user space co-ords?

    Read the article

  • CKEDITOR, is return some strange characters

    - by nobosh
    With CKEDITOR, when I use JS to get the contents of the Text Editor, I'm getting back: <p>\u000a\u0009&nbsp;ad adad ad asd</p>\u000a When I should have gotten: <p>ad adad ad asd</p> Any idea what's going on here? The only difference that could be the cause is that I'm dynamically created textareas on load, and using a class to find the editor: $('.guideItem-textarea').each(function(index, value){ // ID of the textarea var targeteditor = $(this).attr('id'); var targeteditorID = $(this).attr('id').replace('noteguide',''); // Contents in the editor textareacontents = CKEDITOR.instances[targeteditor].getData(); }); Any ideas?

    Read the article

  • gsub! Is modifying unspecified strings

    - by user335729
    I'm extracting some information from an XML file, and I want to perform some modifications on the data while keeping a copy of the original in a variable "origFile". This is what I have: require "rexml/document" include REXML doc = Document.new File.new(thePath) root = doc.root array = [] root.elements.each("dict/string") {|element| array << element} origFile = [] root.elements.each("dict"){|i| origFile << i} theBody = array[6][0].to_s theBody.gsub!(/\&lt;!-- more --\&gt;/, "----------Read More----------") The problem is that after I perform gsub! on theBody, origFile also has the modification. I don't understand why this would be or how to fix it. I would really appreciate your help.

    Read the article

  • Mootools - how to destroy a class instance

    - by Rob
    What I'm trying to do is create a class that I can quickly attach to links, that will fetch and display a thumbnail preview of the document being linked to. Now, I am focusing on ease of use and portability here, I want to simply add a mouseover event to links like this: <a href="some-document.pdf" onmouseover="new TestClass(this)">Testing</a> I realize there are other ways I can go about this that would solve my issue here, and I may end up having to do that, but right now my goal is to implement this as above. I don't want to manually add a mouseout event to each link, and I don't want code anywhere other than within the class (and the mouseover event creating the class instance). The code: TestClass = new Class({ initialize: function(anchor) { this.anchor = $(anchor); if(!this.anchor) return; if(!window.zzz) window.zzz = 0; this.id = ++window.zzz; this.anchor.addEvent('mouseout', function() { // i need to get a reference to this function this.hide(); }.bind(this)); this.show(); }, show: function() { // TODO: cool web 2.0 stuff here! }, hide: function() { alert(this.id); //this.removeEvent('mouseout', ?); // need reference to the function to remove /*** this works, but what if there are unrelated mouseout events? and the class instance still exists! ***/ //this.anchor.removeEvents('mouseout'); //delete(this); // does not work ! //this = null; // invalid assignment! //this = undefined; // invalid assignment! } }); What currently happens with the above code: 1st time out: alerts 1 2nd time out: alerts 1, 2 3rd time out: alerts 1, 2, 3 etc Desired behavior: 1st time out: alerts 1 2nd time out: alerts 2 3rd time out: alerts 3 etc The problem is, each time I mouse over the link, I'm creating a new class instance and appending a new mouseout event for that instance. The class instance also remains in memory indefinitely. On mouseout I need to remove the mouseout event and destroy the class instance, so on subsequent mouseovers we are starting fresh.

    Read the article

  • Accessing the stringValue from NSTextFields on different NIBs

    - by Kyle Zaragoza
    I'm having an extremely difficult time trying to access information from an object (e.g. an NSTextField) that is located on a NIB other than my "MainMenu.nib". My current setup: I have a MainMenu.xib that contains only a toolbar at the top and an NSView. I have four other .xib files containing custom NSViews and each of their File Owner's are assigned to a NSViewController subclass which I have created for each. My MainMenu.xib contains an object that is set to my WindowController subclass that takes care of swapping the fours views into the NSView on my MainMenu.xib. All of this works fantastic. Where I have a problem: I have another class that acts as the brains to my application which sends and receives data from an online server, all of the methods I have created rely on inputs from the user that are located on the individual .xibs that swap into my MainMenu.xib's NSview. Unfortunately I have no idea on how to grab the information from the NSTextFields, textViews, etc. that are located on my individual .xib files. What I've tried: I have tried setting the File Owner's of the four individual .xibs to my "brains" class and connecting outlets defined in my "brains".h, but when I call [textField stringValue] I receive a NULL response. I'm thinking this is because I'm creating multiple instances of my "brains" class but not totally sure. Any help on accessing information from textFields from other nibs would be a great benefit, thanks in advance.

    Read the article

  • Why this doesn't work: [MySQL][ODBC 5.1 Driver]Access denied for user

    - by bvandrunen
    So I know that there is a very similar question to this all over the web as well as stack overflow: http://stackoverflow.com/questions/2539961/error-access-denied-for-user-mysql-server but my question I think is different. So I have set up a linked server and it works...I have the correct permissions set up for my IP's that I am using. However the problem arises when our user "webuser@correctIP" tries to access it. Therefore, any user using window authentication is allowed to access it and works great...but any that are not using windows authentication are blocked. However, I have tried all the common solutions such as setting up a strict password, changing security settings in Microsoft SQL Server etc. Nothing is working. Any help is appreciated. Thanks. FYI: I am using this from Microsoft SQL Server 2008 - mysql (through myphpadmin)

    Read the article

  • Add a child inside a newly created instance, inside of a loop in AS3

    - by HeroicNate
    I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do. var xml:XML; var xmlReq:URLRequest = new URLRequest("xml.xml"); var xmlLoader:URLLoader = new URLLoader(); var imageLoader:Loader; var vidThumbn:ThumbNail; var next_y:Number = 0; for(var i:int = 0; i < xml.downloads.videos.video.length(); i++) { vidThumbn = new ThumbNail(); imageLoader = new Loader(); imageLoader.load(new URLRequest(xml.downloads.videos.video[i].ThumbnailImage)); vidThumbn.y = next_y; vidThumbn.x = 0; next_y += 117; imageLoader.name = xml.downloads.videos.video[i].Files[0].File.URL; videoBox.thumbList.thumbListHolder.addChild(vidThumbn); videoBox.thumbList.thumbListHolder.vidThumbn.addChild(imageLoader); } It dies every time on that last line. How do I refer to that vidThumbn instance so I can add the imageLoader? I don't know what I'm missing. It feels like it should work.

    Read the article

  • iPhone SDK UI element preview

    - by Michael
    Looking for some catalog/gallery(not UICatalog, just images), where I can see preview of each UI element in iPhone SDK, along with corresponding class name(eg datetime picker, calendar, the black switch bar on bottom). This will give me rough idea on which UI elements I can use in my app and go read about corresponding class.

    Read the article

  • global static boolean pointer causes segmentation fault using pthread

    - by asksw0rder
    New to pthread programming, and stuck on this error when working on a C++&C mixed code. What I have done is to call the c code in the thread created by the c++ code. There is a static boolean pointer used in the thread and should got free when the thread finishes. However I noticed that every time when the program processed into the c function, the value of the boolean pointer would be changed and the segmentation fault then happened due to the free(). Detail code is as follows: static bool *is_center; // omit other codes in between ... void streamCluster( PStream* stream) { // some code here ... while(1){ // some code here ... is_center = (bool*)calloc(points.num,sizeof(bool)); // start the parallel thread here. // the c code is invoked in this function. localSearch(&points,kmin, kmax,&kfinal); // parallel free(is_center); } And the function using parallel is as follows (my c code is invoked in each thread): void localSearch( Points* points, long kmin, long kmax, long* kfinal ) { pthread_barrier_t barrier; pthread_t* threads = new pthread_t[nproc]; pkmedian_arg_t* arg = new pkmedian_arg_t[nproc]; pthread_barrier_init(&barrier,NULL,nproc); for( int i = 0; i < nproc; i++ ) { arg[i].points = points; arg[i].kmin = kmin; arg[i].kmax = kmax; arg[i].pid = i; arg[i].kfinal = kfinal; arg[i].barrier = &barrier; pthread_create(threads+i,NULL,localSearchSub,(void*)&arg[i]); } for ( int i = 0; i < nproc; i++) { pthread_join(threads[i],NULL); } delete[] threads; delete[] arg; pthread_barrier_destroy(&barrier); } Finally the function calling my c code: void* localSearchSub(void* arg_) { // omit some initialize code... // my code begin_papi_thread(&eventSet); // Processing k-means, omit codes. // is_center value will be updated correctly // my code end_papi_thread(&eventSet); // when jumping into this, error happens return NULL; } And from gdb, what I have got for the is_center is: Breakpoint 2, localSearchSub (arg_=0x600000000000bc40) at streamcluster.cpp:1711 1711 end_papi_thread(&eventSet); (gdb) s Hardware watchpoint 1: is_center Old value = (bool *) 0x600000000000bba0 New value = (bool *) 0xa93f3 0x400000000000d8d1 in localSearchSub (arg_=0x600000000000bc40) at streamcluster.cpp:1711 1711 end_papi_thread(&eventSet); Any suggestions? Thanks in advance!

    Read the article

  • VB6 code for Reading/Writing Windows Registry values

    - by Clay Nichols
    I'm looking for a good example of reading and writing to the Windows Registry using VB6. Yes, I know there are lots of mediocre examples. I spent an hour googling and testing. Some were incredibly complex, others had only some of the functions, and almost none of it had been vetted in any way (voted on). Since Stack Overflow is intended to the canonical location for answers to programming questions, it seems reasonable to post it here.

    Read the article

  • Limit a process's relative (not absolute) processor consumption in Linux

    - by BobBanana
    What is the standard way in Linux to enforce a system policy to limit the relative CPU use of a single process? That is, on a quad-core machine, I never want a process to use more than 2 CPUs at once, even if the process creates more threads. I do not want an absolute time limit, just a relative limit so that one task cannot dominate the machine. This is also different than renice, which allows a process to use all the resources but just politely step aside if others need them too. ulimit is the usual resource limiting tool, but it does not allow such CPU restrictions.. it can limit the number of processes per user, or absolute CPU time, not restrict the maximum number of active threads of a single process. I've found a couple of user-level tools, like CPUlimit, but not a system level tool or setting. Does such a standard resource controller exist in Linux (Red Hat Enterprise, if it matters.) If there is such a limit imposed, how would a user identify it?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >