Posts

Showing posts from September, 2014

How to perform GroupChat in android using XMPP -

i working on group chat in android using asmack library. able chat single user getting problems in group chat. require tutorial or code perform group chat. i've referenced this stack overflow question , this blog post when looking solution. public void muc_configure(string roomname){ try{ muc = new multiuserchat(xmppsmackconnection.connection, roomname+constant._hostnamewithconf); muc.create("nickname1"); // send empty room configuration form indicates want instant room muc.sendconfigurationform(new form(form.type_submit)); muc.join("nickname1"); muc.invite("column1"+constant._hostnamewithat+"/smack", "meet me in excellent room"); muc.addinvitationrejectionlistener(this); muc.addmessagelistener(this); }catch (exception e) { e.printstacktrace(); } } finally done above method.

javascript - Trying for .show() and .hide() not working -

<div id ="instant-view"> <textarea id="upload-data-text" placeholder="copy & paste data here"></textarea> </div> <script> $("#instant-view").hide(); </script> here the id "#instant-view" not hiding, not getting whats going wrong. using jquery though wrap code inside document's ready event like, $(document).ready(function(){ $("#instant-view").hide(); }) working fiddle

PHP fopen() can't function -

i facing problem php fopen() read files. the error : warning: fopen(\\192.168.183.28\digi_prog\m10\test1\p001.txt): failed open stream: invalid argument in c:\xampp\htdocs\digi\index.php on line 72 and php code : echo $fs = fopen("\\\\192.168.183.28\\digi_prog\\m10\\test1\\p001.txt","r"); strangely, when try open url, it's opened. make sure, file exist. any advice? if read docs see that resource fopen ( string $filename , string $mode [, bool $use_include_path = false [, resource $context ]] ) where filename of form "scheme://...", assumed url , php i suggest use following fopen('http://192.168.183.28/digi_prog/m10/test1/p001.txt','r') or use file_get_contents (after making sure allow_url_fopen set 1)

python - Creating a custom profile with "column username is not unique error" -

i'm trying extend basic user profile in django-allauth. signup form loads correctly, after submitting form there's "column username not unique error" . the project files below: models.py from django.db import models django.contrib.auth.models import user # create models here. class userprofile(models.model): user = models.onetoonefield(user, related_name='userprofile') # additional attributes wish include. website = models.urlfield(blank=true) picture = models.imagefield(upload_to='profile_images', blank=true) has_accepted_tos = models.booleanfield(default=false, verbose_name='i accept site rules') #required_fields = ['has_accepted_tos'] def __unicode__(self): return self.user.username user.profile = property(lambda u:userprofile.objects.get_or_create(user=u)[0]) forms.py from django.contrib.auth import get_user_model .models import us...

eclipse - Android Gingerbread phones are not recognized -

i can connect , use android 3.0+ , 4.0+ devices without problem , can see , use them eclipse well. but, when try connect froyo/gingerbread device pc, not recognized usb device connected it. i did research , tried installing driver own website, installed kies, turned on , off usb debugging, tried connecting storage,etc no, nothing working. being charged when devices connected. pc doesn't see device connected it. my os windows 8.1 - 64bit. while trying, i've followed these links: http://forum.xda-developers.com/showthread.php?t=2327476 http://androidforums.com/samsung-galaxy-y/602088-usb-wont-connect-samsung-galaxy-y.html how run android app in debug mode on samsung galaxy y s5360 any , suggestion solution appreciated. i have found temporary fix now. dznk on topic, i've managed fix problem. http://forums.wpcentral.com/nokia-lumia-920/251273-windows-8-1-n-wont-recognize-my-device.html if change usb slot few times, pc manages see device every ti...

c# - can't get index to work with html razor -

i having major problems indexing html on partial view. model i'm using: [display(resourcetype = typeof(myresources), name = "edittravelviewmodel_timeofdeparture")] [required(errormessage = "{0} måste fyllas i")] public string timeofdeparture { get; set; } [display(resourcetype = typeof(myresources), name = "edittravelviewmodel_dateofdeparture")] [required(errormessage = "{0} måste fyllas i")] public string dateofdeparture { get; set; } and code partial: <li class="clearfix"> @*use http://trentrichardson.com/examples/timepicker/*@ @html.textboxfor(model => model.dateofdeparture, new { @placeholder = myresources.shared_travelpartial_traveldate, @class = "startdate datepicker", @readonly = "readonly", @style ="width: 90px;" }); @html.textboxfor(model => model.timeofdeparture, ...

multithreading - C++: locking mechanism with a container of a set of pointers -

i have a std::map<std::string, something*> mymap where something* can locked because can accessed different threads. since entries in mymap can inserted, have global lock avoid concurrency during "fetch" phase. mymaplock.lock(); something* = mymaplock[key]; mymaplock.unlock(); some.lock(); // some.unlock(); this structure cannot work if want delete entries in mymap, since remove still locked else (but has unlocked mymap). do know of pattern solve problem? you can use std::shared_ptr<something> instead of something * . something object deleted when reference count == 0. if thread has locked something object (and copy of std::shared_ptr<something> mymap ) something object not deleted if other thread removes entry something object mymap .

c# - Error Binding ImageSource to ImageBrush -

i have class called myuser. contains public property "image" follows private imagesource _image; public imagesource image { { return _image; } set { if (value != _image) { _image = value; onpropertychanged("image"); } } } i have wpf usercontrol contains setter fill path user's image. (user myuser object viewmodel) <setter property="fill"> <setter.value> <imagebrush imagesource="{binding path=user.image}" stretch="uniformtofill" /> </setter.value> </setter> i getting error during runtime (not exception) system.windows.data error: 2 : cannot find governing frameworkelement or frameworkcontentelement target element. bindingexpression:path=user.image; dataitem=null; target element 'imagebrush' (hashcode=21084988); target property 'imagesource' (type 'imagesource') ...

c# - How to show a error message when wrong file uploaded other than(jpeg) in ajax_uploadfile asp.net using jquery? -

i working on asp.net ajax_uploadfile here need show error message had given allowedfiletypes="jpg,jpeg,png" here code: <asp:ajaxfileupload runat="server" throbberid="throbber" id="upfile" allowedfiletypes="pdf" onchange="callingerrormesage()" maximumnumberoffiles="5" onclientuploadcomplete="file_upload" /> here script code: <scrpt> function callingerrormesage(){ alert(1); } </script> here code behind: protected void file_upload(object sender, ajaxfileuploadeventargs e) { string filename = e.filename; string strdestpath = server.mappath("~/documents/"); ajaxfileupload1.saveas(@strdestpath + filename); } when uploaded jpeg file it's working fine when need upload other jpeg file need show error message i had given onchange="callingerrormesage()" not working please me on this? you shou...

c - Python memory model for this program -

Image
my query on below program respect symbols storing values , functions, when ran on http://pythontutor.com/ . my question is: how python execution model above program on memory before start interpreting python program? how visualise memory layout? example c executable has code/stack/heap/extra/data segments, example, not comparing is 'const' name of 32/64 bit memory area storing value 2 type assigned integer? add()/sub()/other functions shown in objects column per diagram, so, how perceive functions being stored objects? how visualise it? as per diagram, op function pointer pointing function sub()? every c (compiled language) program has code/data/stack/extra/heap segments loaded in memory before execution. python interpreter create memory layout every python program before start interpreting python program? if yes, how visualise memory layout? it has kind of layout, here heap important part, every object put heap. code segment merely interpreter, da...

What does "THUMB" macro do in ARM-linux code? -

i looking @ head.s arm linux code. know thumb mode is. there 1 line such thumb(it eq) , predefined macro #define thumb(x...) x dotdotdot written. please tell me macro does. entry(stext) setmode psr_f_bit | psr_i_bit | svc_mode, r9 @ ensure svc mode @ , irqs disabled mrc p15, 0, r9, c0, c0 @ processor id bl__lookup_processor_type @ r5=procinfo r9=cpuid movs r10, r5 @ invalid processor (r5=0)? thumb( iteq ) @ force fixup-able long branch encoding beq __error_p @ yes, error 'p' thumb() arm() preprocessor macros used conditionally compile source assembly depending on target instruction set. if kernel being compiled arm target, thumb() macro no-op. on contrary, if kernel being compiled thumb, thumb() macro expanded arguments.

php - Facebook event api to upload cover image -

i have working facebook event creation if set profile picture event working fine while uploading cover image not working , " throws #200 permission error" below code have used post link facebook php sdk: upload event cover photo $cover['cover_url'] = 'http://urlofimage'; $eid = 'xxxxxxxxxxxxxxxxxxxxxx'; $facebook->setfileuploadsupport(true); $eventupdate = $facebook->api( "/" . $eid, 'post', $cover ); but not worked still, can please me. or please mention if possible or not i use code , working fine . $data = array( "access_token"=>$fb_oauth_token, "cover_url" => $image_full, ); remember use accesstoken posting etc. thanks

java - New Android Application wont create an activity eclipse -

when select "new android application" , put in - minimum required sdk:"api4: android 1.6 (donut)" - target sdk:"api4: android 1.6 (donut)" - complex with:"api4: android 1.6 (donut)" - theme:"none" then next >> next >> next, says in "create activity", "this template requires minimum sdk version of @ least 7, current min version 4" installed " android 2.1 (eclair) " because said sdk version 7. i go again , type: - minimum required sdk:"api4: android 1.6 (donut)" - target sdk:"api7:android 2.1 (eclair)" - complex with:"google apis (google inc.) (api7)" - theme:"none" then next >> next >> next, same msg! i go again , put stuff , got " template requires build target api version of @ least 14, , current version 8" , many others no use! the question is, how can make application maps using android 1.6?

rubygems - Fresh Installs of RVM and Ruby 2.1.1 - dyld library/pathing error -

i have been trying install rvm , ruby 2.1.1 onto new mac (os 10.9.2), , seems going until try install version of ruby. my input $ rvm reinstall 2.1 so far good... ruby-2.1.1 - #removing rubies/ruby-2.1.1.. searching binary rubies, might take time. found remote file https://rvm.io/binaries/osx/10.9/x86_64/ruby-2.1.1.tar.bz2 checking requirements osx. certificates in '/usr/local/etc/openssl/cert.pem' date. requirements installation successful. ruby-2.1.1 - #configure ruby-2.1.1 - #download ruby-2.1.1 - #validate archive ruby-2.1.1 - #extract ruby-2.1.1 - #validate binary ruby-2.1.1 - #setup ruby-2.1.1 - #making binaries executable.. ruby-2.1.1 - #downloading rubygems-2.2.2 ruby-2.1.1 - #extracting rubygems-2.2.2.... ruby-2.1.1 - #removing old rubygems......... but then... ruby-2.1.1 - #installing rubygems-2.2.2. error running 'env gem_home= gem_path= /users/dylanoshea/.rvm/rubies/ruby-2.1.1/bin/ruby -d /users/dylanoshea/.rvm/src/rubygems-2.2.2/setup.rb --verbo...

c# - Linq2Twitter Single User Authorisation Null Value Exception -

i've been developing internal asp.net web forms application our business , 1 of requirements display our twitter feed on our portal home page users. for i've decided best use linqtotwitter single user authorisation statuses without them having authenticate own accounts. my main problem @ minute when use auth object twittercontext, returns error on twittercontext saying value cannot null on every internal context object. i've gone through our twitter application settings @ http://dev.twitter.com , have our correct consumer key/token , access key/token. permission application set read-only. there no callback url specified on http://dev.twitter.com website on our internal system (so wouldn't able anyway). going wrong? need forward ports , allow callback through our development machines? here's code prudence. far can see, there nothing wrong it. know set .firstordefault , seeing whether getting (which isn't). thanks can give! :) private async t...

ios - UIActionSheet Crashing when using XCode 5 -

in iphone app displaying simple uiactionsheet , working correctly on xcode 4.6 , want migrate app xcode 5. but when moved xcode 5, app crashing when showing action sheet. i using iphone 4 ios 7 test on both this action sheet code (i removed part of try narrow down issue) uiactionsheet *languagemessage = [[uiactionsheet alloc] initwithtitle:@"title" delegate:nil cancelbuttontitle:@"cancel" destructivebuttontitle:nil otherbuttontitles:nil]; languagemessage.actionsheetstyle=uiactionsheetstyleblacktranslucent; [languagemessage showinview:self.view]; the app crashing ( sigabrt ) on line [languagemessage showinview:self.view]; while debugging self.view not null , read correctly not issue this stack trace * thread #1: tid = 0x19cd1e, 0x3860f688 libobjc.a.dylib`objc_exception_throw, queue = 'com.apple.main-thread, stop reason = breakpoint 35.1 frame #0: 0x3860f688 libobjc.a.dylib`objc_exception_throw frame #1: 0x30bd8bc6 uikit`-[uiactionsheet _...

JK flipflop code in verilog using structural -

i writing verilog program jk flipflop in structural level program follows: module jkstruct(j,k,clk,q,qbar); input j,k,clk; output reg q,qbar; initial begin q=1'b1;qbar=1'b0; end wire x,y,w,z; assign w=q; assign z=qbar; nand n1(x,z,j,clk); nand n2(y,k,w,clk); nand n3(q,x,z); nand n4(qbar,y,w); endmodule erroor:simulator:754 - signal exception_access_violation receivedprinting stacktrace... was appearing on simulator error panel. using xilinx 13.4 licensed version. you initialising outputs initial begin q=1'b1;qbar=1'b0; end when combinatorially driven : nand n3(q,x,z); nand n4(qbar,y,w); the above requires output connected via wire not reg. remove initial, , reg declaration (apply change below), , report if issue still persists. output q,qbar; // output reg q,qbar;

actionscript 3 - How does Flash calculate a DisplayObject's dimensions based on the children? -

i have class called container extends sprite , adds ability set width , height manually, scalex , scaley remaining 1. i have put such class sprite , noticed sprite measures internal calculations, not getting width / height getters. what math , how can extend force sprite consider extended width , height getters while doing internal measures? the math lies within getboundary() function that's called of children , own graphics determine coordinates edges of entire sprite's display list. that's why setting width without scaling might not useful. if still wish this, first make fields contain info on set width , height, update on container.width , container.height assignment, override getters on width , height, returning maximum of stored width/height , calls of super.width , super.height . var storedwidth:number=0; // not have nans public override function width():number { var w:number=super.width; // width math if (storedwidth>w) w=storedwidth...

pass mat from dll c++ to imagesource c# -

i'm working visual c# 2010, , send image dll c++ visual c# 2010. image has 166*166*24 send image dll c++ c#. i'm using code: main.cpp unsigned char* test() { read image filename mat originalimg = imread(filename, cv_load_image_color); return (originalimg.data);} originalimg.data return pointer image. main.h extern "c" { __declspec(dllexport) unsigned char* test();} and in program visual c#, use code: [dllimport("testng.dll", callingconvention = callingconvention.cdecl)] private static extern intptr test(); intptr intptr1; bitmapimage bitmapimage; calling c++ dll intptr1 = test(1); if (intptr1.tostring().compareto("0") != 0) { create bitmap pointer bitmap bitmap = new bitmap(166, 166, 3 * 166, system.drawing.imaging.pixelformat.format24b...

c# - MVC, Saving Data into 2 or more Related models from a single Form / View .? -

my model: (i) transaction public class transaction { [key] public int transactionid { get; set; } public datetime onwarddate { get; set; } public datetime returndate { get; set; } public virtual userprofile user { get; set; } } (ii) user public class userprofile { [key] [databasegeneratedattribute(databasegeneratedoption.identity)] public int userid { get; set; } public string username { get; set; } private userdetails _details = new userdetails(); public virtual userdetails details { { return _details; } } } (ii) userdetails public class userdetails { [key] public int detailsid { get; set; } public string dlnum { get; set; } } my controller create transaction: // get: /transaction/create public actionresult create() { return view(); } // // post: /transaction/create [httppost] [validateantiforgerytoken] public actionresult create(transactio...

sql - Complex sorting in access -

i trying pull out course funding information database, using ms access. funding attached each student in db. number of students on more 1 course. funding attached student, causing displayed against several courses, totals high. funding needs shown against main course student on. i have hirachy of course codes (the opening digit tells sort of code is). need able specify, example, when student on 'n*' code course , 'm*' course, funding should come through against m course. there 7 different combinations of course codes. at moment have 2 queries. first pulls out: student id, funding, course code. second counts student id, , sums funding, grouping course code. how , should go implementing sql required stop funding being duplicated? thanks query 1 (efa funding base query): select [learner id], [learner funding], [course code] learner inner join learningdelivery ld on learner.learner_id = ld.learne...

php - How to re-order array elements if there is a specific key? -

it seems wordpress wp_query doesn't provide option of order post_status. , want list private posts before other posts. posts array looks this: $posts = array( 0=>object{ .... }, 1=>object{ .... }, .... ); each post object has key of 'post_status'. want move post beginning of array if value 'private', . how? use usort() : usort($posts, ($a, $b) { return ($a->post_status < $b->post_status) ? -1 : 1; });

android - Spinners and problems with Context? -

i'm working on fragment class next: public class demandfragment extends fragment implements locationlistener{... i have declared this: spinner spinner_loc; arrayadapter<string> spinner_loc_adapter = null; @override public void onactivitycreated(bundle state){ super.onactivitycreated(state); bundle bundle = this.getarguments(); source_category = integer.parseint(bundle.getstring("category")); preparespinner(); ... and have next function it's called onactivitycreated method (to modularize code): private void preparespinner(){ spinner_loc = (spinner) getview().findviewbyid(r.id.spinner_loc); ... and further... inside of preparespinner() method. spinner_loc = null; spinner_loc_adapter = null; spinner_loc_adapter = new arrayadapter<string>(getactivity(), r.layout.spinner_content, values); spinner_loc.setadapter(spinner_loc_adapter); spinner_loc_adapter.notifydatasetchanged(); value array of str...

javascript - this is a program dealing with canvas and java script -

bellow code program suppose lower blinking ball bottom of screen , stay blinking @ bottom. process suppose take place gradually (incrementing factor of 10) happens suddenly. should do? <!doctype html> <html> <head> <meta charset="iso-8859-1"> <title>animationdemocanvas.html &copy; kari laitinen</title> <script type="text/javascript"> var ball_center_point_x = 300 ; var ball_center_point_y = 240 ; var current_ball_color = "cyan" ; var ball_must_be_shown = true ; function draw_on_canvas() { var canvas = document.getelementbyid( "animation_demo_canvas" ) ; var context = canvas.getcontext("2d") ; context.fillstyle = "rgb( 255, 255, 210 )" ; context.fillrect( 0, 0, canvas.width, canvas.height ) ; if ( ball_must_be_shown == true ) { context.fillstyle = current_ball_color ; context.beginpath() ; ball_center_point_y +=10; ...

java - Storing strings that appear after a word in a document into arrays and combining them -

i have file, which, among other data, has following lines: group = a_1 group_sub = a101,a102,a103,a104 group = a_2 group_sub = a201,a202,a203,a204,a205,a206 a1 males, , a2 females. need read in file, , each time reaches word "group", store name of group (for example, a_1) in array. move on next line , store subjects in group array [a101,a102,a103,a104]. , need merge name of group subjects in group males , females so: [a_1,a101,a102,a103,a104] (for males) [a_2,a201,a202,a203,a204,a205,a206] (for females) my code: public class test { file fromfile = new file(filename); bufferedreader br = new bufferedreader(new filereader(fromfile)); string line; while ((line = br.readline()) != null){ string[]grouptitle = null; string[]groupsubjects = null; if (line.startswith("group")){ string[] title = line.split("= "); grouptitle= title[1].split(" "); ...

coq - How to apply rewrite inside a specific subexpression? -

i'm using online book "software foundations" learn coq. in second chapter, asked prove "plus_assoc" theorem: theorem plus_assoc : forall n m p : nat, n + (m + p) = (n + m) + p. i make use of 2 proven theorems: theorem plus_comm : forall n m : nat, n + m = m + n. theorem plus_n_sm : forall n m : nat, s (n + m) = n + (s m). i prove plus_assoc theorem using induction on n: proof. intros n m p. induction n [ | n' ]. reflexivity. rewrite plus_comm. rewrite <- plus_n_sm. rewrite plus_comm. rewrite ihn'. symmetry. rewrite plus_comm. at point, context (*) is: 1 subgoals case := "n = s n'" : string.string n' : nat m : nat p : nat ihn' : n' + (m + p) = n' + m + p ______________________________________(1/1) p + (s n' + m) = s (n' + m + p) i use plus_comm get p + (m + s n') = s (n' + m + p) then plus_n_sm p + s (m + n') = s (n' + m + p) then again ...

c# - Slow Line drawing in GDI+ -

i'm new winforms , gdi+, come wpf background. using simple code below draw 1000 lines noticed doesn't draw lines @ once wpf does. slow , process of drawing noticable. missing in code below? private void button1_click(object sender, eventargs e) { graphics g; g = creategraphics(); var pn = new pen(color.wheat, 1); var x = 0; var y = 0; var n = 0; while (n < 1000) { x = x + 5; if (x > 1200) { x = 0; y = y + 15; } g.drawline(pn, x, y, x, y + 10); n++; } } i've created small solution compare drawing speed, can try on own machine. link solution

java - ANT - How i cant move File to JAR -

i've had edited ant build process. here working list: create copy of src folder , selfwritten anttask obfuscated strings ant creates jar <jar> the jar obfuscated proguard an additional file must copied jar jar signed the bodled step question. how can copy single file root directory of jar. must make step here! before or after won't work: before: proguard try obfuscate file , gives exceptions. after cant work, file must signed. anyone have smart idea? here minified version of ant build script: <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <project basedir="." default="default" name="demo"> <property environment="env" /> <property name="debuglevel" value="source,lines,vars" /> <property name="target" value="1.7" /> <property name="source" value="1.7" /> <...

nosql - Is it possible to configure ArangoDB to make snapshots of the graph database at specific times? -

so far know arangodb uses mvcc , therefore creates revisions of nodes , edges undefined period of time until garbage collector removes them. i implement graph database schema , need keep state of database @ specific times. means configures times when database management system take snapshot of state (e.g. every week). so question in short: possible keep revisions/versions of nodes/edges in arangodb (or maybe plugin) , timestamp of creation? if no, there other graph databases able this? i think can use arangodump ( link arangodb client tools manual ) binary create snapshot @ desired point in time. save state of database (or specific collections contain graph data) json files, can used auditing or later reloading data. arangodump contained in arangodb distributions. the data dumped arangodump not contain creation timestamps, if need them can make them part of data filling "created" attribute in each node / edge when create it. i hope helps.

tween - libGDX game stuck on screen show() - hide() loop -

i creating first game in libgdx , splash screen, making use of universal tween engine. using aurelien ribon 's demo except own images. problem occurs when splash screen ends, gives call launcher , there on, call various classes extending test class. found no clean way of giving control levelselector class implements screen , uses stage rendering. whenever control goes class, calls show() , without entering render(), calls hide() . continues till application stopped. while app class (i.e. main class) render() continues called continuosly. have figured out work around causes memory problems , making game slow. can please tell me how stop rendering of app & transfer control class? my workaround works follows : when click on play (extends test ), in initialize static flag of app : inplay set. in app render(), if isplay set, setscreen levelselector. in levelselector, if click on level, set static flag of app : inlevel. in app render(), if inlevel set, setscreen l...

How to build release apk with netbeans 8.0 and cordova -

i'm using netbeans 8.0 , want build html 5 cordova app. how build release apk? you have compile cordova application, on device or emulator. have find folder: documents\netbeansprojects\ro\platforms\android\ant-build inside folder there apk file.

objective c - Update plist with json data in iOS -

i saving json content in plist file. //fetch json nsstring *filepath = [[nsbundle mainbundle] pathforresource:@"sample" oftype:@"json"]; nsdata *data = [nsdata datawithcontentsoffile:filepath]; //get json in dictionary format nsdictionary *dict = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:nil]; nslog(@"dict: %@",dict); //get plist path nsstring *errordesc; nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory1 = [paths objectatindex:0]; nsstring *plistpath = [documentsdirectory1 stringbyappendingpathcomponent:@"sampledata.plist"]; nslog(@"plistpath : %@",plistpath); //save data json plist nsstring *error; data = [nspropertylistserialization datafrompropertylist:dict format:nspropertylistxmlformat_v1_0 errordescription:&error]; if(data) ...

ios - UIrefreshcontrol with an asynchronous request -

i have tableview need implement uirefreshcontroller . works fine. want when pull , refresh, needs request again. @ moment there issue when remove fixtures objects, if don't add same fixtures there. what doing wrong? [self firstrequest]; //is request the code: -(void)viewdidappear:(bool)animated { uirefreshcontrol *refreshcontrol = [[uirefreshcontrol alloc] init]; [refreshcontrol addtarget:self action:@selector(refresh:) forcontrolevents:uicontroleventvaluechanged]; [self.thetableview addsubview:refreshcontrol]; } - (void)refresh:(uirefreshcontrol *)refreshcontrol { [fixtures removeallobjects]; [self firstrequest]; [refreshcontrol endrefreshing]; } the problem everytime reload add duplicates , when use [fixtures removeallobjects]; it gives me following error: terminating app due uncaught exception 'nsrangeexception', reason: '*** -[__nsarrayi objectatindex:]: index 3 beyond bounds empty array'